This is the mail archive of the gcc-bugs@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]

Possible bug in tradcpp.c?


While creating an unrelated patch to the trad* files, I noticed that
there is a possible bug in tradcpp.c:

 > void
 > special_symbol (hp, op)
 >      HASHNODE *hp;
 >      FILE_BUF *op;
 > {
 >   char *buf = 0;
 >   [...]
 > 
 >   switch (hp->type) {
 >   case T_FILE:
 >   case T_BASE_FILE:
 >     {
 >       const char *string;
 >       if (hp->type == T_FILE)
 > 	string = ip->fname;
 >       else
 > 	string = instack[0].fname;
 > 
 >       if (string)
 > 	{
 > 	  buf = (char *) alloca (3 + strlen (string));
 > 	  sprintf (buf, "\"%s\"", string);
 > 	}
 >       else
 > 	strcpy (buf, "\"\"");
 > 
 >       break;
 >     }

I think that last strcpy will try to copy two double quotes into a
NULL pointer buf.  However I can't figure out a testcase to verify
this.  I think the fix would be to simply assign buf = (char *) "".
Thoughts?

		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions

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