[Bug driver/10961] New: read_specs -- compilers[n_compilers].cpp_spec not initialized

taylor@candd.org gcc-bugzilla@gcc.gnu.org
Fri May 23 23:37:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10961

           Summary: read_specs -- compilers[n_compilers].cpp_spec not
                    initialized
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: driver
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: taylor@candd.org
                CC: gcc-bugs@gcc.gnu.org
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: all

In read_specs (gcc.c), there's the lines:

	  /* Add this pair to the vector.  */
	  compilers
	    = ((struct compiler *)
	       xrealloc (compilers,
			 (n_compilers + 2) * sizeof (struct compiler)));

	  compilers[n_compilers].suffix = suffix;
	  compilers[n_compilers].spec = spec;
	  n_compilers++;
	  memset (&compilers[n_compilers], 0, sizeof compilers[n_compilers]);

Now, compilers[n_compilers].cpp_spec is not initialized here.

Yes, most people don't define compilers in the specs file; and yes, there's
a chance that the memory returned by xrealloc might be freshly obtained from
the OS (and hence zero'ed for security reasons), but you can't count on
either of those.  It should be zero'ed.

The one line fix is obvious.

This bug is present in all versions from 3.2.3 onwards (and probably goes
back quite a ways).



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the Gcc-bugs mailing list