This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

(C++) memory overrun fix for arglist in lang_specific_driver


The following fixes a memory overrun problem in arglist. The problem is
that the num_args doesn't leave room for the final NULL, and the problem
shows up on platforms where MATH_LIBRARY is "" and hence need_math is
0.

Easy way to reproduce is the following:
  
  $ ./g++ -B./ -c -v foo.c

on a platform where MATH_LIBRARY is "" (such as x86-mingw32).

Tue Aug 17 12:04:14 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* g++spec.c (lang_specific_driver): Add room for NULL in arglist.

Index: g++spec.c
===================================================================
RCS file: /homes/khan/src/CVSROOT/gcc-2.95/gcc/cp/g++spec.c,v
retrieving revision 1.1.1.1
diff -u -3 -p -r1.1.1.1 g++spec.c
--- g++spec.c	1999/06/14 21:05:21	1.1.1.1
+++ g++spec.c	1999/08/17 17:03:12
@@ -197,7 +197,7 @@ lang_specific_driver (fn, in_argc, in_ar
       return;
     }
 
-  num_args = argc + added + need_math;
+  num_args = argc + added + need_math + 1;
   arglist = (char **) xmalloc (num_args * sizeof (char *));
 
   /* NOTE: We start at 1 now, not 0.  */

Regards,
Mumit


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]