Author: tkreuzer
Date: Wed Jul 4 18:58:09 2012
New Revision: 56827
URL:
http://svn.reactos.org/svn/reactos?rev=56827&view=rev
Log:
[CRT]
Fix a bug in streamout() causing "%.*s" to crash when the buffer was not zero
terminaed. Found by Thomas Faber.
Modified:
trunk/reactos/lib/sdk/crt/CMakeLists.txt
trunk/reactos/lib/sdk/crt/printf/streamout.c
Modified: trunk/reactos/lib/sdk/crt/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/CMakeLists.txt…
==============================================================================
--- trunk/reactos/lib/sdk/crt/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/CMakeLists.txt [iso-8859-1] Wed Jul 4 18:58:09 2012
@@ -34,6 +34,8 @@
printf/wvsprintfW.c
printf/wvsnprintfA.c
printf/wvsnprintfW.c
+ string/strnlen.c
+ string/wcsnlen.c
string/mbstowcs_nt.c
string/wcstombs_nt.c)
Modified: trunk/reactos/lib/sdk/crt/printf/streamout.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/printf/streamo…
==============================================================================
--- trunk/reactos/lib/sdk/crt/printf/streamout.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/printf/streamout.c [iso-8859-1] Wed Jul 4 18:58:09 2012
@@ -508,10 +508,9 @@
}
if (flags & FLAG_WIDECHAR)
- len = wcslen((wchar_t*)string);
+ len = wcsnlen((wchar_t*)string, (unsigned)precision);
else
- len = strlen((char*)string);
- if (precision >= 0 && len > (unsigned)precision) len =
precision;
+ len = strnlen((char*)string, (unsigned)precision);
precision = 0;
break;