readlink -f still segfaults

Natanael Copa natanael.copa at gmail.com
Fri May 5 10:54:50 UTC 2006


On Fri, 2006-05-05 at 11:44 +0200, Bernhard Fischer wrote:
> On Fri, May 05, 2006 at 12:29:26PM +0200, Natanael Copa wrote:
> >On Fri, 2006-05-05 at 11:29 +0200, Natanael Copa wrote:
> >> I discovered my hotplug scripts fails caused by readlink segfaulting. I
> >> googled and found that it has been seen before:
> >>
> >> http://www.busybox.net/lists/busybox/2006-January/017795.html
> >>
> >> Looks like it never got a conclusion.
> >
> >The problem is the realpath(...., NULL) gnu extension mentioned here:
> >http://www.busybox.net/lists/busybox/2006-January/017777.html
> >
> >The attached patch fixes the problem by calling xmalloc instead of
> >relying on realpath to do it.
> >
> >Please commit (also to busybox_1_1_stable)
> 
> Looks ok to me.
> 
> Can you please add a
> if (ENABLE_CLEANUP && (opt & READLINK_FLAG_f))
> 	free;

It looks to me that it always needs to be free'd.
The previous way realpath(..., NULL) gnu extension allocates for you
when buffer is NULL.

When no -f is specified xreadlink will use xrealloc to allocate memory.

I cannot see why

if (ENABLE_CLEANUP && (opt & READLINK_FLAG_f)) free(buf);

should be there.

Am I missing something?

> 
> and make a simple
> testsuite/readlink.tests

I'm pretty new to this. Are there any docs on how to create testcases?

> 
> That'd be awesome!




More information about the busybox mailing list