From: u-igbb@aetey.se
To: musl@lists.openwall.com
Subject: Re: memmem() - is it correct?
Date: Wed, 9 Apr 2014 14:14:55 +0200 [thread overview]
Message-ID: <20140409121455.GH21662@example.net> (raw)
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
next reply other threads:[~2014-04-09 12:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-09 12:14 u-igbb [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-04-09 10:08 u-igbb
2014-04-09 10:19 ` Timo Teras
[not found] ` <20140409104925.GE21662@example.net>
2014-04-09 12:51 ` Timo Teras
2014-04-09 12:54 ` Timo Teras
2014-04-10 1:15 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140409121455.GH21662@example.net \
--to=u-igbb@aetey.se \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).