readlink -f still segfaults

Bernhard Fischer rep.nop at aon.at
Fri May 5 10:12:26 UTC 2006


On Fri, May 05, 2006 at 12:54:50PM +0200, Natanael Copa wrote:
>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?

I didn't look, my bad. You are right, the buffer is already free'd.
>
>> 
>> and make a simple
>> testsuite/readlink.tests
>
>I'm pretty new to this. Are there any docs on how to create testcases?

Look at e.g. testsuite/sort.tests

You can run tests conditionally to a feature by saying:
optional FEATURE_READLINK_FOLLOW
and reset to unconditionally running tests with
optional ""
if you choose to run generic stuff after conditional ones.
busybox.tests has an example for this, but for readlink, i'd check the
gerenic stuff first and then the single optional FEATURE.

See?



More information about the busybox mailing list