From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119530 invoked by alias); 30 Oct 2019 11:10:30 -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 119519 invoked by uid 89); 30 Oct 2019 11:10:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=H*i:sk:875zk63, H*f:sk:875zk63, HContent-Transfer-Encoding:8bit X-HELO: mx1.suse.de From: Andreas Schwab To: Florian Weimer Cc: libc-alpha@sourceware.org Subject: Re: [review] manual: Clarify strnlen, wcsnlen, strndup null termination behavior References: <87a79i33kt.fsf@oldenburg2.str.redhat.com> <875zk6337v.fsf@oldenburg2.str.redhat.com> X-Yow: ONE: I will donate my entire ``BABY HUEY'' comic book collection to the downtown PLASMA CENTER.. TWO: I won't START a BAND called ``KHADAFY & THE HIT SQUAD''.. THREE: I won't ever TUMBLE DRY my FOX TERRIER again!! Date: Wed, 30 Oct 2019 11:10:00 -0000 In-Reply-To: <875zk6337v.fsf@oldenburg2.str.redhat.com> (Florian Weimer's message of "Wed, 30 Oct 2019 12:03:16 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2019-10/txt/msg00915.txt.bz2 On Okt 30 2019, Florian Weimer wrote: > * Andreas Schwab: > >> On Okt 30 2019, Florian Weimer wrote: >> >>> * Andreas Schwab: >>> >>>> On Okt 30 2019, Florian Weimer (Code Review) wrote: >>>> >>>>> +Note that @var{s} must be an array of at least @var{maxlen} bytes. It >>>>> +is undefined to call @code{strnlen} on a shorter array, even if it is >>>>> +known that the shorter array contains a null terminator. >>>> >>>> This is not true. strnlen _always_ stops before the null byte. >>> >>> This is not how it is specified in POSIX. >> >> Yes, it is. >> >> The strnlen() function shall return the number of bytes preceding >> the first null byte in the array to which s points, if s contains a >> null byte within the first maxlen bytes; otherwise, it shall return >> maxlen. >> >> There is nothing undefined here. Your interpretation would be >> completely useless anyway. > > It says “array” Yes, because a null terminator is not required. > But it does NOT say that reading stops after the first null terminator. Yes, it does, see above. Otherwise it doesn't make sense. Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."