From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4850 Path: news.gmane.org!not-for-mail From: u-igbb@aetey.se Newsgroups: gmane.linux.lib.musl.general Subject: Re: memmem() - is it correct? Date: Wed, 9 Apr 2014 14:14:55 +0200 Message-ID: <20140409121455.GH21662@example.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1397045731 2828 80.91.229.3 (9 Apr 2014 12:15:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Apr 2014 12:15:31 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4854-gllmg-musl=m.gmane.org@lists.openwall.com Wed Apr 09 14:15:24 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WXrPX-0002Mj-8J for gllmg-musl@plane.gmane.org; Wed, 09 Apr 2014 14:15:23 +0200 Original-Received: (qmail 16022 invoked by uid 550); 9 Apr 2014 12:15:22 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 16011 invoked from network); 9 Apr 2014 12:15:22 -0000 X-T2-Spam-Status: No, hits=2.3 required=5.0 tests=BAYES_50, FAKE_REPLY_C Received-SPF: none receiver=mailfe07.swip.net; client-ip=96.44.189.102; envelope-from=u-igbb@aetey.se Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:4850 Archived-At: 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