From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) by sourceware.org (Postfix) with ESMTPS id C0F64385801A for ; Sat, 27 Mar 2021 17:51:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C0F64385801A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=deneb.enyo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fw@deneb.enyo.de Received: from [172.17.203.2] (port=55617 helo=deneb.enyo.de) by albireo.enyo.de ([172.17.140.2]) with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1lQD5b-0002hB-Ew; Sat, 27 Mar 2021 17:51:11 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1lQD5b-0005YQ-D4; Sat, 27 Mar 2021 18:51:11 +0100 From: Florian Weimer To: "H.J. Lu via Libc-alpha" Subject: Re: [PATCH] Check that strnlen won't go beyond the maximum length References: <20210327162449.3215538-1-hjl.tools@gmail.com> Date: Sat, 27 Mar 2021 18:51:11 +0100 In-Reply-To: <20210327162449.3215538-1-hjl.tools@gmail.com> (H. J. Lu via Libc-alpha's message of "Sat, 27 Mar 2021 09:24:49 -0700") Message-ID: <87ft0g8oz4.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Mar 2021 17:51:13 -0000 * H. J. Lu via Libc-alpha: > Run strnlen tests on strings without the null byte around the page > boundary. > --- > string/test-strnlen.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/string/test-strnlen.c b/string/test-strnlen.c > index 61eb521dc1..a49d93afa2 100644 > --- a/string/test-strnlen.c > +++ b/string/test-strnlen.c > @@ -196,6 +196,31 @@ do_page_tests (void) > } > } > > +/* Tests meant to unveil fail on implementation that does not access bytes > + without the null character around the page boundary accordingly. */ I don't understand the comment. Based on it, I would have expected a null byte at the page boundary, which is incorrectly ignored by the implementation. > +static void > +do_page_2_tests (void) > +{ > + size_t i, exp_len, offset; > + size_t last_offset = page_size / sizeof (CHAR); > + > + CHAR *s = (CHAR *) buf2; > + memset (s, 65, page_size); I think this needs to use wmemset for the WIDE case, see wcsmbs/test-wcsnlen.c.