This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH, RFA] Fix basename bug in symtab.c
- To: Mark Kettenis <kettenis at wins dot uva dot nl>
- Subject: Re: [PATCH, RFA] Fix basename bug in symtab.c
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 14 May 2001 16:01:57 -0400
- Cc: gdb-patches at sources dot redhat dot com, jimb at cygnus dot com,ezannoni at cygnus dot com
- References: <200105132045.f4DKjpm03579@delius.kettenis.local>
> [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