From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10326 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: strftime sets errno to 22 Date: Sun, 24 Jul 2016 11:34:16 -0400 Message-ID: <20160724153416.GN15995@brightrain.aerifal.cx> References: <20160724014740.GM15995@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1469374484 30956 80.91.229.3 (24 Jul 2016 15:34:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 24 Jul 2016 15:34:44 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10339-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jul 24 17:34:39 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1bRLQJ-0006Jl-23 for gllmg-musl@m.gmane.org; Sun, 24 Jul 2016 17:34:35 +0200 Original-Received: (qmail 3512 invoked by uid 550); 24 Jul 2016 15:34:31 -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 3491 invoked from network); 24 Jul 2016 15:34:30 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10326 Archived-At: On Sun, Jul 24, 2016 at 09:59:26AM +0300, Alexander Monakov wrote: > On Sat, 23 Jul 2016, Rich Felker wrote: > > With that said, at the time this was reported on IRC I looked for the > > cause of errno being set to EINVAL and didn't see it. It might be nice > > to know why it's happening, just in case some unintended code paths > > with nontrivial cost are getting pulled in. > > nsz mentioned on irc it's from strtoul call (when no digits are seen). It looks like this is something that should be fixed, just because calling strtoul without checking isdigit allows invalid formats to be accepted (strtoul consumes leading whitespace and signs, both of which are unwatned). Probably we want: - width = strtoul(f, &p, 10); + width = isdigit(*f) ? strtoul(f, &p, 10) : 0; Thoughts? Rich