On Sat, 20 Feb 2016 13:54:49 +0900, Alexandre Julliard wrote:
Hugh McMaster writes:
@@ -243,8 +243,17 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r { LPWSTR rest; DWORD val;
BOOL overflow = FALSE;
if (data[1] == 'x')
{
WCHAR *ptr = &data[2];
while (*ptr == '0')
ptr++;
if (strlenW(ptr)> 8)
overflow = TRUE;
} val = strtoulW(data, &rest, (data[1] == 'x') ? 16 : 10);
You won't be able to catch base 10 overflows this way. It probably needs a more general solution (and some more test cases...)
That's a good point. The best solution would be to check if (val == ULONG_MAX && errno == ERANGE), but it seems our strtoulW implementation doesn't have errno support.
According to the C89 standard, "The strtoul function returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct value would cause overflow, ULONG_MAX is returned, and the value of the macro ERANGE is stored in errno ." [1]
Setting errno shouldn't be difficult, but I can research other solutions too, if you like.
If I do set errno for strtoulW, I'll set it for strtolW as well.