Jacek Caban : setupapi: Fix hex digit check in SetupGetBinaryField.
Alexandre Julliard
julliard at winehq.org
Thu Feb 6 15:44:17 CST 2020
Module: wine
Branch: master
Commit: d580d2c2fdad7f6f00dd12923e475298c019b660
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d580d2c2fdad7f6f00dd12923e475298c019b660
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Feb 6 14:00:33 2020 +0100
setupapi: Fix hex digit check in SetupGetBinaryField.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/setupapi/parser.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c
index 193e5e1f97..560c2401b8 100644
--- a/dlls/setupapi/parser.c
+++ b/dlls/setupapi/parser.c
@@ -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;
}
More information about the wine-cvs
mailing list