|
Message-ID: <20140409155116.30ec723a@vostro> Date: Wed, 9 Apr 2014 15:51:16 +0300 From: Timo Teras <timo.teras@....fi> To: u-igbb@...ey.se Cc: musl@...ts.openwall.com Subject: Re: memmem() - is it correct? On Wed, 9 Apr 2014 12:49:25 +0200 u-igbb@...ey.se wrote: > On Wed, Apr 09, 2014 at 01:19:03PM +0300, Timo Teras wrote: > > > const char *haystack = "abcde"; > > > return(!memmem(haystack, 4, "cde", 3)); > > > > returns 1 (as I would expect it to) if linked against uclibc > > > returns 0 if linked against musl > > > (on ia32) > > I guess you misinterpreted the test code, there is a '!' which > transforms a returned pointer (success) to 0 exit status in main() > and vice versa. Right. Should have read it more carefully. Yes, looks like musl bug. Perhaps something like the following is in place: diff --git a/src/string/memmem.c b/src/string/memmem.c index 5211d75..0594fea 100644 --- a/src/string/memmem.c +++ b/src/string/memmem.c @@ -138,7 +138,9 @@ void *memmem(const void *h0, size_t k, const void *n0, size_t l) /* Use faster algorithms for short needles */ h = memchr(h0, *n, k); - if (!h || l==1) return (void *)h; + if (!h) return 0; + if (l==1) return (void *)h; + k -= h - h0; if (l==2) return twobyte_memmem(h, k, n); if (l==3) return threebyte_memmem(h, k, n); if (l==4) return fourbyte_memmem(h, k, n);
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.