Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 31 May 2018 09:47:19 +0300
From: Andrei Vagin <>
Cc: Andrei Vagin <>
Subject: [PATCH] scanf: handle the L modifier for integers

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

Signed-off-by: Andrei Vagin <>
 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;
 	case SIZE_ll:
+	case SIZE_L:
 		*(long long *)dest = i;

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.