[PATCH, RFA] Fix basename bug in symtab.c

Andrew Cagney ac131313@cygnus.com
Mon May 14 13:02:00 GMT 2001


> [Jim, Elena, sorry I keep saying cygnus instead of redhat :-(]
> 
> Here is a patch that fixes the problems discussed on the discussion
> list.  Eli pretty much convinced me that this is the right approach.
> We can still discuss the other uses of basename() in GDB, but since
> this fixes a rather serious bug on FreeBSD (and I suppose other
> systems as well), I'd like to get this in ASAP.


Just to be clear on one thing, the bug occures on FreeBSD.  It isn't a 
FreeBSD bug :-).  To quote the opengroup standard:

> #include <libgen.h>
> char *basename(char *path);

...

> The basename() function may modify the string pointed to by path, and may return a pointer to static storage that may then be overwritten by a subsequent call to basename().
> 
> This interface need not be reentrant.


Any way, looking at libiberty/lbasename.c, it casts:

	(const char*) -> (char *)

so I'd not call that function safe either (actually grrrr).

	Andrew




More information about the Gdb-patches mailing list