Piotr Caban : msvcrt: Fix handling of unsigned chars in scanf format.

Alexandre Julliard julliard at winehq.org
Thu Jul 20 12:11:28 CDT 2017


Module: wine
Branch: stable
Commit: 10e6abd7b3f0e11f12fc6379fe69bba754700a3d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=10e6abd7b3f0e11f12fc6379fe69bba754700a3d

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Mar 31 15:02:48 2017 +0200

msvcrt: Fix handling of unsigned chars in scanf format.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 32bb8d9068ae5282b6b10734579aaa2d5195a5af)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/msvcrt/scanf.h       | 2 +-
 dlls/msvcrt/tests/scanf.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

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)




More information about the wine-cvs mailing list