From deb18d21206cca68f6d6dfa4e4e17eef88d8d2df Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Sat, 10 Jan 2004 14:22:14 +0000 Subject: [PATCH] - Check first for string length and second for the string end in string/stringw. svn path=/trunk/; revision=7546 --- reactos/lib/msvcrt/stdio/vfprintf.c | 4 ++-- reactos/lib/msvcrt/stdio/vfwprint.c | 6 +++--- reactos/lib/ntdll/stdio/sprintf.c | 6 +++--- reactos/lib/ntdll/stdio/swprintf.c | 6 +++--- reactos/ntoskrnl/rtl/sprintf.c | 6 +++--- reactos/ntoskrnl/rtl/swprintf.c | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/reactos/lib/msvcrt/stdio/vfprintf.c b/reactos/lib/msvcrt/stdio/vfprintf.c index 2755826d370..c95864f3d75 100644 --- a/reactos/lib/msvcrt/stdio/vfprintf.c +++ b/reactos/lib/msvcrt/stdio/vfprintf.c @@ -617,7 +617,7 @@ static int string(FILE *f, const char* s, int len, int field_width, int precisio if (len == -1) { len = 0; - while (s[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && s[len]) len++; } else @@ -661,7 +661,7 @@ static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int pre if (len == -1) { len = 0; - while (sw[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && sw[len]) len++; } else diff --git a/reactos/lib/msvcrt/stdio/vfwprint.c b/reactos/lib/msvcrt/stdio/vfwprint.c index 9c8863148c8..73b3bd061d2 100644 --- a/reactos/lib/msvcrt/stdio/vfwprint.c +++ b/reactos/lib/msvcrt/stdio/vfwprint.c @@ -608,7 +608,7 @@ static int string(FILE *f, const char* s, int len, int field_width, int precisio if (len == -1) { len = 0; - while (s[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && s[len]) len++; } else @@ -652,7 +652,7 @@ static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int pre if (len == -1) { len = 0; - while (sw[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && sw[len]) len++; } else @@ -685,7 +685,7 @@ static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int pre int __vfwprintf(FILE *f, const wchar_t *fmt, va_list args) { - int len; + int len = 0; ULONGLONG num; int base; long double _ldouble; diff --git a/reactos/lib/ntdll/stdio/sprintf.c b/reactos/lib/ntdll/stdio/sprintf.c index 7d422494479..b55d3d25106 100644 --- a/reactos/lib/ntdll/stdio/sprintf.c +++ b/reactos/lib/ntdll/stdio/sprintf.c @@ -1,4 +1,4 @@ -/* $Id: sprintf.c,v 1.13 2003/09/12 17:51:48 vizzini Exp $ +/* $Id: sprintf.c,v 1.14 2004/01/10 14:22:14 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -165,7 +165,7 @@ string(char* buf, char* end, const char* s, int len, int field_width, int precis if (len == -1) { len = 0; - while (s[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && s[len]) len++; } else @@ -210,7 +210,7 @@ stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int p if (len == -1) { len = 0; - while (sw[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && sw[len]) len++; } else diff --git a/reactos/lib/ntdll/stdio/swprintf.c b/reactos/lib/ntdll/stdio/swprintf.c index c8e76e1252b..c58ac5fe50a 100644 --- a/reactos/lib/ntdll/stdio/swprintf.c +++ b/reactos/lib/ntdll/stdio/swprintf.c @@ -1,4 +1,4 @@ -/* $Id: swprintf.c,v 1.15 2003/09/12 17:51:48 vizzini Exp $ +/* $Id: swprintf.c,v 1.16 2004/01/10 14:22:14 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -167,7 +167,7 @@ string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int if (len == -1) { len = 0; - while (s[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && s[len]) len++; } else @@ -212,7 +212,7 @@ stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, if (len == -1) { len = 0; - while (sw[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && sw[len]) len++; } else diff --git a/reactos/ntoskrnl/rtl/sprintf.c b/reactos/ntoskrnl/rtl/sprintf.c index 8fb223f27ad..f1e44592e69 100644 --- a/reactos/ntoskrnl/rtl/sprintf.c +++ b/reactos/ntoskrnl/rtl/sprintf.c @@ -1,4 +1,4 @@ -/* $Id: sprintf.c,v 1.15 2003/12/30 18:52:06 fireball Exp $ +/* $Id: sprintf.c,v 1.16 2004/01/10 14:22:14 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -182,7 +182,7 @@ string(char* buf, char* end, const char* s, int len, int field_width, int precis if (len == -1) { len = 0; - while (s[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && s[len]) len++; } else @@ -227,7 +227,7 @@ stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int p if (len == -1) { len = 0; - while (sw[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && sw[len]) len++; } else diff --git a/reactos/ntoskrnl/rtl/swprintf.c b/reactos/ntoskrnl/rtl/swprintf.c index 2f401af8700..9f54433cf53 100644 --- a/reactos/ntoskrnl/rtl/swprintf.c +++ b/reactos/ntoskrnl/rtl/swprintf.c @@ -1,4 +1,4 @@ -/* $Id: swprintf.c,v 1.13 2003/12/30 18:52:06 fireball Exp $ +/* $Id: swprintf.c,v 1.14 2004/01/10 14:22:14 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -193,7 +193,7 @@ string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int if (len == -1) { len = 0; - while (s[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && s[len]) len++; } else @@ -238,7 +238,7 @@ stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, if (len == -1) { len = 0; - while (sw[len] && (unsigned int)len < (unsigned int)precision) + while ((unsigned int)len < (unsigned int)precision && sw[len]) len++; } else