Francois Gouget : msvcrt: Old versions of _vsnprintf() treat the size as a signed int.

Alexandre Julliard julliard at winehq.org
Thu Feb 20 18:26:15 CST 2020


Module: wine
Branch: master
Commit: c2404ba333abd08054084285191f22eba5c9f7fc
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c2404ba333abd08054084285191f22eba5c9f7fc

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Feb 20 19:27:49 2020 +0100

msvcrt: Old versions of _vsnprintf() treat the size as a signed int.

When they see -1 they consider that the buffer is too small and return
an error. So impose a 2 GB limit on sprintf() for backward
compatibility with XP and 2003.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 include/msvcrt/stdio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h
index 33d33aa7b4..be8c1e485f 100644
--- a/include/msvcrt/stdio.h
+++ b/include/msvcrt/stdio.h
@@ -286,7 +286,7 @@ static inline int WINAPIV sprintf(char *buffer, const char *format, ...)
     __ms_va_list args;
 
     __ms_va_start(args, format);
-    ret = _vsnprintf(buffer, (size_t)-1, format, args);
+    ret = _vsnprintf(buffer, (size_t)_CRT_INT_MAX, format, args);
     __ms_va_end(args);
     return ret;
 }




More information about the wine-cvs mailing list