From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10891 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Edge case: strtol with base==1 Date: Wed, 4 Jan 2017 19:52:46 -0500 Message-ID: <20170105005246.GB7642@brightrain.aerifal.cx> References: <20170102020448.GW1555@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1483577585 30662 195.159.176.226 (5 Jan 2017 00:53:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 5 Jan 2017 00:53:05 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-10904-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jan 05 01:53:01 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1cOwIa-0006oa-GW for gllmg-musl@m.gmane.org; Thu, 05 Jan 2017 01:52:56 +0100 Original-Received: (qmail 11407 invoked by uid 550); 5 Jan 2017 00:52:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 11380 invoked from network); 5 Jan 2017 00:52:58 -0000 Content-Disposition: inline In-Reply-To: <20170102020448.GW1555@brightrain.aerifal.cx> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10891 Archived-At: On Sun, Jan 01, 2017 at 09:04:48PM -0500, Rich Felker wrote: > On Sun, Jan 01, 2017 at 04:45:19AM -0600, Ryan Prichard wrote: > > Hi, > > > > I noticed that musl's strtol function allows a base of 1 by parsing strings > > of only zeros. With all other bases less than 0 or greater than 36, strtol > > fails and sets errno to EINVAL. > > > > Is this an oversight? > > > > Not that it especially *matters*, but my guess is that the behavior isn't > > POSIX conforming: > > - POSIX defines valid "subject sequences" for bases of 0 and 2-36. > > - "In other than the C or POSIX locale, additional locale-specific subject > > sequence forms may be accepted." > > > > In the C locale, musl is accepting a subject sequence of all zeroes, which > > POSIX doesn't define for a base of 1. > > > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/strtol.html > > Indeed, I think you're right. ISO C does not specify the behavior when > the base is invalid (it's UB), but POSIX does impose an error > requirement. It's not clear that it requires other bases to be > unsupported, just that an error be produced if the base is > unsupported, but I think the right behavior is not to support a > nonsense "base 1". Committing a fix. Thanks. Rich