public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Keith Packard <keithp@keithp.com>
To: newlib@sourceware.org
Subject: [PATCH] stdio: Parse 0x0p+00 correctly in scanf
Date: Fri, 18 Jun 2021 11:11:19 -0700	[thread overview]
Message-ID: <20210618181119.1609818-1-keithp@keithp.com> (raw)

The scanf code was skipping the '0' after the 'x' causing the
resulting buffer to contain an invalid number when passed to strtod.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 newlib/libc/stdio/vfscanf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index 1d5e6512a..037692531 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -1628,6 +1628,7 @@ __SVFSCANF_R (struct _reent *rptr,
 		      && zeroes == 1)
 		    {
 		      flags |= HEXFLT;
+                      flags &= ~NDIGITS;
 		      /* We skipped the first zero, so we have to add
 			 it now to the buffer. */
 		      *p++ = '0';
-- 
2.32.0


                 reply	other threads:[~2021-06-18 18:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210618181119.1609818-1-keithp@keithp.com \
    --to=keithp@keithp.com \
    --cc=newlib@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).