From: Andrei Vagin <avagin@virtuozzo.com>
To: musl@lists.openwall.com
Cc: Andrei Vagin <avagin@virtuozzo.com>
Subject: [PATCH] scanf: handle the L modifier for integers
Date: Thu, 31 May 2018 09:47:19 +0300 [thread overview]
Message-ID: <20180531064719.6805-1-avagin@virtuozzo.com> (raw)
Look at this code:
char str[] = "sigmask: 0x200";
long long mask = 0;
int ret;
ret = sscanf(str, "sigmask: %Lx", &mask));
printf("%d %llx\n", ret, mask);
Without this patch, ret will be 1 and mask will be 0. It is obviously
incorrect. According to the man page, L should work like ll:
L Indicates that the conversion will be either e, f, or g and the
next pointer is a pointer to long double or the conversion will
be d, i, o, u, or x and the next pointer is a pointer to long
long.
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
src/stdio/vfscanf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c
index 9e030fc4..4d0d771e 100644
--- a/src/stdio/vfscanf.c
+++ b/src/stdio/vfscanf.c
@@ -36,6 +36,7 @@ static void store_int(void *dest, int size, unsigned long long i)
*(long *)dest = i;
break;
case SIZE_ll:
+ case SIZE_L:
*(long long *)dest = i;
break;
}
--
2.14.3
next reply other threads:[~2018-05-31 6:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-31 6:47 Andrei Vagin [this message]
2018-05-31 14:20 ` Laurent Bercot
2018-05-31 19:00 ` Andrei Vagin
2018-05-31 20:44 ` Natanael Copa
2018-05-31 21:21 ` Andrei Vagin
2018-05-31 23:44 ` Rich Felker
2018-06-01 0:30 ` Szabolcs Nagy
2018-06-01 0:59 ` Rich Felker
2018-06-01 7:36 ` Andrei Vagin
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=20180531064719.6805-1-avagin@virtuozzo.com \
--to=avagin@virtuozzo.com \
--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).