This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Possible bug in tradcpp.c?
- To: neilb at earthling dot net, zack at wolery dot stanford dot edu
- Subject: Possible bug in tradcpp.c?
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Mon, 6 Nov 2000 11:11:34 -0500 (EST)
- Cc: gcc-bugs at gcc dot gnu dot org
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