Commit d580d2c2 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

setupapi: Fix hex digit check in SetupGetBinaryField.

parent bf95bccf
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment