[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    [PATCH] msvcrt: Fix handling of unsigned chars in scanf format
From:       Piotr Caban <piotr () codeweavers ! com>
Date:       2017-03-31 13:02:48
Message-ID: 9b3366ab-8044-d6b5-0691-a172a806bcb9 () codeweavers ! com
[Download RAW message or body]

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
---
  dlls/msvcrt/scanf.h       | 2 +-
  dlls/msvcrt/tests/scanf.c | 4 ++++
  2 files changed, 5 insertions(+), 1 deletion(-)



["0001-msvcrt-Fix-handling-of-unsigned-chars-in-scanf-format.txt" (text/x-patch)]

diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h
index b2e6bd7..0fa1e6f 100644
--- a/dlls/msvcrt/scanf.h
+++ b/dlls/msvcrt/scanf.h
@@ -699,7 +699,7 @@ _FUNCTION_ {
 	 * a matching non-white-space character. */
         else {
             /* check for character match */
-            if (nch == *format) {
+            if (nch == (unsigned char)*format) {
 		nch = _GETC_(file);
             } else break;
         }
diff --git a/dlls/msvcrt/tests/scanf.c b/dlls/msvcrt/tests/scanf.c
index 6cb85fa..ecb270b 100644
--- a/dlls/msvcrt/tests/scanf.c
+++ b/dlls/msvcrt/tests/scanf.c
@@ -251,6 +251,10 @@ static void test_sscanf( void )
     ok(ret == 2, "got %d\n", ret);
     ok(!strcmp(buffer, "test"), "buf %s\n", buffer);
     ok(!strcmp(buffer1, "value\xda"), "buf %s\n", buffer1);
+
+    ret = sscanf("\x81test", "\x81%s", buffer);
+    ok(ret == 1, "got %d\n", ret);
+    ok(!strcmp(buffer, "test"), "buf = %s\n", buffer);
 }
 
 static void test_sscanf_s(void)


[Attachment #4 (text/plain)]




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic