Date: Wed, 9 Apr 2014 14:14:55 +0200 From: u-igbb@...ey.se To: musl@...ts.openwall.com Subject: Re: memmem() - is it correct? 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) > musl looks correct to me. "abcde" is five bytes. You test for 4 bytes I am testing for 3 bytes "cde" inside 4 bytes "abcd", this should not be successful. > so it's infact searching from haystack equivalent of "abcd". Exactly. It does _not_ contain "cde". This should return NULL from the memmem() and hence 1 from main(). > I'd say uclibc is off-by-one, and broken. 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. Rune
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.