From 98c133312f20670afed6bbc54cc9aa43ed6c65fa Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 7 Jan 2008 19:56:15 +0100 Subject: [PATCH] regedit: Fixed parsing of hex sequences. --- programs/regedit/regproc.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index fe5323e696c..705faf675e4 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -92,15 +92,10 @@ static BYTE* convertHexCSVToHex(char *str, DWORD *size) *size=0; while (*s != '\0') { UINT wc; - char dummy; + char *end; - if (s[1] != ',' && s[1] != '\0' && s[2] != ',' && s[2] != '\0') { - fprintf(stderr,"%s: ERROR converting CSV hex stream. Invalid sequence at '%s'\n", - getAppName(), s); - HeapFree(GetProcessHeap(), 0, data); - return NULL; - } - if (sscanf(s, "%x%c", &wc, &dummy) < 1 || dummy != ',') { + wc = strtoul(s,&end,16); + if (end == s || wc > 0xff || (*end && *end != ',')) { fprintf(stderr,"%s: ERROR converting CSV hex stream. Invalid value at '%s'\n", getAppName(), s); HeapFree(GetProcessHeap(), 0, data); @@ -108,10 +103,8 @@ static BYTE* convertHexCSVToHex(char *str, DWORD *size) } *d++ =(BYTE)wc; (*size)++; - - /* Skip one or two digits and any comma */ - while (*s && *s!=',') s++; - if (*s) s++; + if (*end) end++; + s = end; } return data;