This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


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

Re: [PATCH] basename buffer gets spammed in `ld'


On Thu, Jul 12, 2001 at 02:49:13PM -0400, DJ Delorie wrote:
> 
> > 2001-07-11  David O'Brien  <obrien@FreeBSD.org>
> > 
> > 	* emultempl/elf32.em: Make all basename calls safe by using
> > 	lbasename() with non-changing buffers.
> 
> Make sure the branch has lbasename in libiberty, else OK (unless Phil
> B disagrees, of course ;).
> 
> > -      filename = xstrdup (basename (entry->filename));
> > +      filename = lbasename (entry->filename);
> 
> Are you sure the xstrdup is no longer needed with lbasename?

Depends on why the xstrdup was there.  If it was there because of
basename()'s internal non-reentrant buff, then it is not needed.  As you
know that is how lbasename() differs from basename().

If entry->filename's contents are not static across the run, then it
would still be needed.  My read and test cases showed the patch was fine
(with no test regression for i386-known-freebsd4.3.  Since all the other
basename() calls needed to be wrapped with xstrdup it appeared to me this
basename() call was wrapped in xstrdup for the same reason.

HOWEVER, I would not mind at all a second set of eyes looking into it.

-- 
-- David  (obrien@FreeBSD.org)


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