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 4884 invoked from network); 9 Mar 2020 18:59:10 -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; 9 Mar 2020 18:59:10 -0000 Received: (qmail 24199 invoked by uid 550); 9 Mar 2020 18:32:28 -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 24169 invoked from network); 9 Mar 2020 18:32:27 -0000 From: Alexander Monakov To: musl@lists.openwall.com Date: Mon, 9 Mar 2020 21:32:16 +0300 Message-Id: <20200309183216.31559-1-amonakov@ispras.ru> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.11.0" Subject: [musl] [PATCH] remove redundant condition in memccpy This is a multi-part message in MIME format. --------------2.11.0 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit 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(-) --------------2.11.0 Content-Type: text/x-patch; name="0321-remove-redundant-condition-in-memccpy.patch" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="0321-remove-redundant-condition-in-memccpy.patch" 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; } --------------2.11.0--