From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64100 invoked by alias); 11 Sep 2018 12:58:38 -0000 Mailing-List: contact libc-help-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: libc-help-owner@sourceware.org Received: (qmail 64087 invoked by uid 89); 11 Sep 2018 12:58:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=wake, Wake, Hx-languages-length:2325, forest X-HELO: mail-yw1-f52.google.com Received: from mail-yw1-f52.google.com (HELO mail-yw1-f52.google.com) (209.85.161.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Sep 2018 12:58:36 +0000 Received: by mail-yw1-f52.google.com with SMTP id m62-v6so9151654ywd.6 for ; Tue, 11 Sep 2018 05:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wfu.edu; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=+1u6CuYyLKsAJV0wbN1pdY/ypnlWq+MEQkYOq1oKlcg=; b=Itp31cVLdrTFNEWZdVxUkh/fI8if3Pz//aNr/uSvpT4YMC/rDUhb+JsjVpQ1vXQz6Z FjZZXHyamglG7fQPcQRQeNv4FfExTDK+RjFZTatHSgBj9hyUwCI3uSufJX8M+6SL0Zoo aPjxMgA5PXkE/fvOgATrodzAwIdCd8zmYepuw= Return-Path: Received: from robroy (host116.dyn128.wfu.edu. [152.17.128.116]) by smtp.gmail.com with ESMTPSA id t124-v6sm11665637ywt.105.2018.09.11.05.58.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Sep 2018 05:58:33 -0700 (PDT) Date: Tue, 11 Sep 2018 12:58:00 -0000 From: Allin Cottrell To: Michael Brunnbauer cc: libc-help@sourceware.org Subject: Re: my strstr is broken In-Reply-To: <20180911102711.GA31876@netestate.de> Message-ID: References: <20180910144752.GA29636@netestate.de> <20180911102711.GA31876@netestate.de> User-Agent: Alpine 2.21 (LNX 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1745527554-657431625-1536670687=:32470" X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00002.txt.bz2 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1745527554-657431625-1536670687=:32470 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 8BIT Content-length: 2911 On Tue, 11 Sep 2018, Michael Brunnbauer wrote: > hi all, > > I assume it cannot be reproduced and is limited to my build? > > Any ideas/hints for me? The fact that the needle is 513 bytes and occurs at > an offset of 513 bytes in the haystack should provide some clue? > > cu, > brunni > > On Mon, Sep 10, 2018 at 04:47:52PM +0200, Michael Brunnbauer wrote: >> >> can someone reproduce this with 2.28 (program exits with return code 255)? >> >> ----------------------------------------------------------- >> #include >> >> int main (void) >> { >> char* i = " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; >> char* n = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; >> if (!strstr(i,n)) return 255; >> return 0; >> } Since it's difficult to verify your long strings in email I tried the following variant of your test: #include #include int main (void) { char h[513*2+1]; char n[513+1]; char *s; int i; for (i=0; i<513; i++) { n[i] = 'x'; h[i] = ' '; h[i+513] = 'x'; } n[513] = '\0'; h[513*2] = '\0'; printf("h=\"%s\"\n", h); printf("n=\"%s\"\n", n); s = strstr(h, n); printf("s = %p\n", (void *) s); printf("strcmp(n, s) = %d\n", strcmp(s, n)); return 0; } Compiled with gcc 8.2.1 20180831 (Arch) the output is s = 0x7ffe8771ae51 strcmp(n, s) = 0 -- Allin Cottrell Department of Economics Wake Forest University, NC --1745527554-657431625-1536670687=:32470--