2011-02-28 Michael Snyder <msnyder@vmware.com>
authorMichael Snyder <msnyder@vmware.com>
Tue, 1 Mar 2011 01:58:33 +0000 (01:58 +0000)
committerMichael Snyder <msnyder@vmware.com>
Tue, 1 Mar 2011 01:58:33 +0000 (01:58 +0000)
* coffread.c (coff_getfilename): Add check to avoid overflow.

gdb/ChangeLog
gdb/coffread.c

index b1b8bf9d0a45369febe02fcb7b3abf201ea80c33..557f89f1ff124381795cde346b152e50c19be11f 100644 (file)
@@ -1,5 +1,7 @@
 2011-02-28  Michael Snyder  <msnyder@vmware.com>
 
+       * coffread.c (coff_getfilename): Add check to avoid overflow.
+
        * objc-lang.c (selectors_info): Add a small safety margin to 
        avoid overflow.
        (classes_info): Error out on too long REGEXP.
index 156661128e2ac1e8743c33f081e91ed4ea7f64e8..9df775d46b9421c6c1d2dea6a54568f04357d55f 100644 (file)
@@ -1316,7 +1316,11 @@ coff_getfilename (union internal_auxent *aux_entry)
   char *result;
 
   if (aux_entry->x_file.x_n.x_zeroes == 0)
-    strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset);
+    {
+      if (strlen (stringtab + aux_entry->x_file.x_n.x_offset) >= BUFSIZ)
+       internal_error (__FILE__, __LINE__, _("coff file name too long"));
+      strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset);
+    }
   else
     {
       strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);