setupapi: Fix hex digit check in SetupGetBinaryField.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bf95bccfaf
commit
d580d2c2fd
|
@ -1803,6 +1803,15 @@ BOOL WINAPI SetupGetIntField( PINFCONTEXT context, DWORD index, PINT result )
|
|||
}
|
||||
|
||||
|
||||
static int xdigit_to_int(WCHAR c)
|
||||
{
|
||||
if ('0' <= c && c <= '9') return c - '0';
|
||||
if ('a' <= c && c <= 'f') return c - 'a' + 10;
|
||||
if ('A' <= c && c <= 'F') return c - 'A' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SetupGetBinaryField (SETUPAPI.@)
|
||||
*/
|
||||
|
@ -1837,15 +1846,15 @@ BOOL WINAPI SetupGetBinaryField( PINFCONTEXT context, DWORD index, BYTE *buffer,
|
|||
{
|
||||
const WCHAR *p;
|
||||
DWORD value = 0;
|
||||
for (p = field->text; *p && iswxdigit(*p); p++)
|
||||
int d;
|
||||
for (p = field->text; *p && (d = xdigit_to_int(*p)) != -1; p++)
|
||||
{
|
||||
if ((value <<= 4) > 255)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_DATA );
|
||||
return FALSE;
|
||||
}
|
||||
if (*p <= '9') value |= (*p - '0');
|
||||
else value |= (towlower(*p) - 'a' + 10);
|
||||
value |= d;
|
||||
}
|
||||
buffer[i - index] = value;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue