Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180531064719.6805-1-avagin@virtuozzo.com>
Date: Thu, 31 May 2018 09:47:19 +0300
From: Andrei Vagin <avagin@...tuozzo.com>
To: musl@...ts.openwall.com
Cc: Andrei Vagin <avagin@...tuozzo.com>
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
   long.

Signed-off-by: Andrei Vagin <avagin@...tuozzo.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

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.