mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: strftime sets errno to 22
Date: Sun, 24 Jul 2016 11:34:16 -0400	[thread overview]
Message-ID: <20160724153416.GN15995@brightrain.aerifal.cx> (raw)
In-Reply-To: <alpine.LNX.2.20.13.1607240957420.13668@monopod.intra.ispras.ru>

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


      reply	other threads:[~2016-07-24 15:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-24  1:17 Alba Pompeo
2016-07-24  1:47 ` Rich Felker
2016-07-24  6:59   ` Alexander Monakov
2016-07-24 15:34     ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160724153416.GN15995@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).