libwine: Use UINT_MAX and 'unsigned int' for conversion with strtoulW
Hugh McMaster
hugh.mcmaster at outlook.com
Mon Aug 15 07:21:39 CDT 2016
When __WORDSIZE is 64, ULONG_MAX is much greater than UINT_MAX. This
means we do not detect an expected overflow on 64-bit operating
systems for tests using DWORD.
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
libs/wine/string.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libs/wine/string.c b/libs/wine/string.c
index 7aa981f..04e65a2 100644
--- a/libs/wine/string.c
+++ b/libs/wine/string.c
@@ -192,9 +192,9 @@ noconv:
unsigned long int strtoulW( const WCHAR *nptr, WCHAR **endptr, int base )
{
int negative;
- register unsigned long int cutoff;
+ register unsigned int cutoff;
register unsigned int cutlim;
- register unsigned long int i;
+ register unsigned int i;
register const WCHAR *s;
register WCHAR c;
const WCHAR *save, *end;
@@ -237,8 +237,8 @@ unsigned long int strtoulW( const WCHAR *nptr, WCHAR **endptr, int base )
save = s;
end = NULL;
- cutoff = ULONG_MAX / (unsigned long int) base;
- cutlim = ULONG_MAX % (unsigned long int) base;
+ cutoff = UINT_MAX / (unsigned int) base;
+ cutlim = UINT_MAX % (unsigned int) base;
overflow = 0;
i = 0;
@@ -260,7 +260,7 @@ unsigned long int strtoulW( const WCHAR *nptr, WCHAR **endptr, int base )
overflow = 1;
else
{
- i *= (unsigned long int) base;
+ i *= (unsigned int) base;
i += c;
}
}
@@ -277,7 +277,7 @@ unsigned long int strtoulW( const WCHAR *nptr, WCHAR **endptr, int base )
if (overflow)
{
errno = ERANGE;
- return ULONG_MAX;
+ return UINT_MAX;
}
/* Return the result of the appropriate sign. */
--
2.7.4
More information about the wine-patches
mailing list