[RFC] strrstr function in libbb failes on some corner cases

Bernhard Fischer rep.dot.nop at gmail.com
Sun Jun 15 21:21:43 UTC 2008


On Sun, Jun 15, 2008 at 11:06:17PM +0200, Tito wrote:
>Hi,
>while inspecting the last changes in busybox code I hit some issues in
>libbb/strrstr.c. The strrtstr function fails on some corner cases of a little
>test program I wrote (and bombs out on NULL pointers):

This was intended, see below.

>For the moment there is no diff but just a drop in replacement
>for strrstr.c for testing and improvement by the list members.
>There is a little size increase:

heh, i wouldn't call 50% a "little", but ok.

Ultimately i don't care, though. I just put in the smallest version for
depmod knowing that it will segfault left and right if somebody throws
NULL on it, since it was enough for depmod.

Doesn't it suffice if we just
if (haystack == NULL || needle == NULL) return NULL and keep the strcmp?


>scripts/bloat-o-meter busybox_old busybox_unstripped
>function                                             old     new   delta
>strrstr                                               53      73     +20
>------------------------------------------------------------------------------
>(add/remove: 0/0 grow/shrink: 1/0 up/down: 20/0)               Total: 20 bytes
>
>The strrstr function at the moment is used only in depmod 
>so the depmod author should check if this new implementation
>is suitable to be used.



More information about the busybox mailing list