From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28738 invoked by alias); 30 Oct 2019 16:58:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 28725 invoked by uid 89); 30 Oct 2019 16:58:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=H*f:sk:mvma79i, H*i:sk:mvma79i, texts X-HELO: mailbackend.panix.com MIME-Version: 1.0 References: <87a79i33kt.fsf@oldenburg2.str.redhat.com> <875zk6337v.fsf@oldenburg2.str.redhat.com> In-Reply-To: From: Zack Weinberg Date: Wed, 30 Oct 2019 16:58:00 -0000 Message-ID: Subject: Re: [review] manual: Clarify strnlen, wcsnlen, strndup null termination behavior To: Andreas Schwab Cc: Florian Weimer , GNU C Library Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2019-10/txt/msg00932.txt.bz2 On Wed, Oct 30, 2019 at 12:47 PM Andreas Schwab wrote: > On Okt 30 2019, Zack Weinberg wrote: > > On Wed, Oct 30, 2019 at 12:20 PM Andreas Schwab wrote: > >> On Okt 30 2019, Zack Weinberg wrote: > >> > >> > It says that accesses beyond maxlen are forbidden, but it *doesn't* > >> > say that accesses beyond the first NUL are forbidden; therefore they > >> > are allowed. > >> > >> Neither does it say that about strncpy or strncat. > > > > I don't see why that would change anything. > > That means that strncpy (x, "a", 10) is undefined. Yes, that could be a defect in the specification of strncpy (I can argue either way about what the parenthetical "(bytes that follow a NUL character are not copied)" means). How does text's presence or absence in the specification of strncpy change anything about the requirements on strnlen? zw