[WINESYNC] setupapi: Fix hex digit check in SetupGetBinaryField.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id d580d2c2fdad7f6f00dd12923e475298c019b660 by Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
winesync 2023-09-25 19:51:19 +02:00 committed by Hermès Bélusca-Maïto
parent 68a2aa3658
commit f4792e103a
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 13 additions and 4 deletions

View file

@ -1966,6 +1966,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.@)
*/
@ -2000,15 +2009,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;
}

View file

@ -10,4 +10,4 @@ files:
dlls/setupapi/setupcab.c: dll/win32/setupapi/setupcab.c
dlls/setupapi/stringtable.c: dll/win32/setupapi/stringtable_wine.c
tags:
wine: 4a3cd01bd150c27d7fd40d04fc92b173f2f988af
wine: d580d2c2fdad7f6f00dd12923e475298c019b660