Hugh McMaster hugh.mcmaster@outlook.com writes:
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com
programs/regedit/regproc.c | 29 ++++++++++++++++++++++++----- programs/regedit/tests/regedit.c | 4 ++-- 2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index e0049c6..c8149f5 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -146,15 +146,34 @@ static char* GetMultiByteStringN(const WCHAR* strW, int chars, DWORD* len) */ static BOOL convertHexToDWord(WCHAR* str, DWORD *dw) {
- char buf[9];
- char *buf; char dummy;
- BOOL ret = TRUE;
- WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL);
- if (lstrlenW(str) > 8 || sscanf(buf, "%x%c", dw, &dummy) != 1) {
- buf = GetMultiByteString(str);
- if (!buf) return FALSE;
- if (strlen(buf) > 8) /* Look for any characters after the DWORD string */
- {
char *p = buf + 8;
while (*p == ' ' || *p == '\t') p++;
if (*p != ';')
{
HeapFree(GetProcessHeap(), 0, buf);
return FALSE;
}
buf[8] = 0;
- }
- if (sscanf(buf, "%x%c", dw, &dummy) != 1)
- { output_message(STRING_INVALID_HEX);
return FALSE;
}ret = FALSE;
It may be a good idea to write tests for dwords with different numbers of digits, it's not clear to me that this would be doing the right thing.