mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] scanf: handle the L modifier for integers
@ 2018-05-31  6:47 Andrei Vagin
  2018-05-31 14:20 ` Laurent Bercot
  2018-05-31 19:00 ` Andrei Vagin
  0 siblings, 2 replies; 9+ messages in thread
From: Andrei Vagin @ 2018-05-31  6:47 UTC (permalink / raw)
  To: musl; +Cc: Andrei Vagin

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-06-01  7:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-31  6:47 [PATCH] scanf: handle the L modifier for integers Andrei Vagin
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

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).