msvcrt: [3/3] printf buffer overrun tests

Jesse Allen the3dfxdude at gmail.com
Mon Nov 13 21:56:19 CST 2006


Shows the initial problem with not checking for very large precision. Also
shows one reason why we might need extra bytes.
-------------- next part --------------
diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c
index b60dc17..7613c91 100644
--- a/dlls/msvcrt/tests/printf.c
+++ b/dlls/msvcrt/tests/printf.c
@@ -187,6 +187,18 @@ static void test_sprintf( void )
     r = sprintf(buffer,format,(LONGLONG)100);
     ok(!strcmp(buffer,"+00100  ") && r==8,"#-+ 08.5I64d failed: '%s'\n", buffer);
 
+    format = "%.80I64d";
+    r = sprintf(buffer,format,(LONGLONG)1);
+    ok(r==80,"%s format failed\n", format);
+
+    format = "% .80I64d";
+    r = sprintf(buffer,format,(LONGLONG)1);
+    ok(r==81,"%s format failed\n", format);
+
+    format = "% .80d";
+    r = sprintf(buffer,format,1);
+    ok(r==81,"%s format failed\n", format);
+
     format = "%lld";
     r = sprintf(buffer,format,((ULONGLONG)0xffffffff)*0xffffffff);
     ok(!strcmp(buffer, "1"), "Problem with \"ll\" interpretation\n");
-- 
1.4.2.1


More information about the wine-patches mailing list