From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RDNS_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 28018 invoked from network); 20 Mar 2020 19:46:44 -0000 Received-SPF: pass (mother.openwall.net: domain of lists.openwall.com designates 195.42.179.200 as permitted sender) receiver=inbox.vuxu.org; client-ip=195.42.179.200 envelope-from= Received: from unknown (HELO mother.openwall.net) (195.42.179.200) by inbox.vuxu.org with ESMTP; 20 Mar 2020 19:46:44 -0000 Received: (qmail 9934 invoked by uid 550); 20 Mar 2020 19:46:42 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 9916 invoked from network); 20 Mar 2020 19:46:42 -0000 Date: Fri, 20 Mar 2020 15:46:30 -0400 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20200320194630.GE11469@brightrain.aerifal.cx> References: <20200309183216.31559-1-amonakov@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200309183216.31559-1-amonakov@ispras.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] remove redundant condition in memccpy On Mon, Mar 09, 2020 at 09:32:16PM +0300, Alexander Monakov wrote: > > Commit d9bdfd164 ("fix memccpy to not access buffer past given size") > correctly added a check for 'n' nonzero, but made the pre-existing test > '*s==c' redundant: n!=0 implies *s==c. Remove the unnecessary check. > > Reported by Alexey Izbyshev. > --- > > Let me also point out that the aforementioned change did not appear > on this mailing list. > > Alexander > > src/string/memccpy.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/string/memccpy.c b/src/string/memccpy.c > index 00c18e2b..3b0a3700 100644 > --- a/src/string/memccpy.c > +++ b/src/string/memccpy.c > @@ -29,6 +29,6 @@ void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n) > #endif > for (; n && (*d=*s)!=c; n--, s++, d++); > tail: > - if (n && *s==c) return d+1; > + if (n) return d+1; > return 0; > } Thanks, applying. Rich