[ros-diffs] [greatlrd] 22081: fixing two hiden bug in reactos,
null termante the string right at end, code tested in vs,
but it seam no affact on wine test mscvrt printf test. What hell is the
snprintf function call to ??
greatlrd at svn.reactos.org
greatlrd at svn.reactos.org
Sun May 28 02:51:17 CEST 2006
Author: greatlrd
Date: Sun May 28 04:51:16 2006
New Revision: 22081
URL: http://svn.reactos.ru/svn/reactos?rev=22081&view=rev
Log:
fixing two hiden bug in reactos, null termante the string right at end, code tested in vs, but it seam no affact on wine test mscvrt printf test. What hell is the snprintf function call to ??
Modified:
trunk/reactos/lib/rtl/sprintf.c
trunk/reactos/lib/rtl/swprintf.c
Modified: trunk/reactos/lib/rtl/sprintf.c
URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/rtl/sprintf.c?rev=22081&r1=22080&r2=22081&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/sprintf.c (original)
+++ trunk/reactos/lib/rtl/sprintf.c Sun May 28 04:51:16 2006
@@ -253,6 +253,8 @@
number of chars for from string */
int qualifier; /* 'h', 'l', 'L', 'I' or 'w' for integer fields */
+ /* clear the string buffer with zero so we do not need NULL terment it at end */
+
str = buf;
end = buf + cnt - 1;
if (end < buf - 1) {
@@ -501,8 +503,20 @@
if (str <= end)
*str = '\0';
else if (cnt > 0)
+ {
/* don't write out a null byte if the buf size is zero */
- *end = '\0';
+ //*end = '\0';
+ if (str-buf >=cnt )
+ {
+ *end = '\0';
+ }
+ else
+ {
+ end++;
+ *end = '\0';
+ }
+
+ }
return str-buf;
}
Modified: trunk/reactos/lib/rtl/swprintf.c
URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/rtl/swprintf.c?rev=22081&r1=22080&r2=22081&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/swprintf.c (original)
+++ trunk/reactos/lib/rtl/swprintf.c Sun May 28 04:51:16 2006
@@ -500,9 +500,21 @@
}
if (str <= end)
*str = L'\0';
- else if (cnt > 0)
+ else if (cnt > 0)
+ {
/* don't write out a null byte if the buf size is zero */
- *end = L'\0';
+ //*end = '\0';
+ if (str-buf >=cnt )
+ {
+ *end = L'\0';
+ }
+ else
+ {
+ end++;
+ *end = L'\0';
+ }
+
+ }
return str-buf;
}
More information about the Ros-diffs
mailing list