[PATCH 7/7] reg: Explicitly use base 10 or base 16 with strtolW

Hugh McMaster hugh.mcmaster at outlook.com
Sun Feb 14 18:38:37 CST 2016


All Windows versions, except XP, parse the number 0123 as decimal.
(XP parses 0123 as octal).

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/reg/reg.c       | 4 +++-
 programs/reg/tests/reg.c | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index aacea2d..1bdf73f 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -238,8 +238,10 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
         case REG_DWORD:
         {
             LPWSTR rest;
+            int base;
             DWORD val;
-            val = strtolW(data, &rest, 0);
+            base = (data[1] == 'x') ? 16 : 10;
+            val = strtolW(data, &rest, base);
             if (*rest || data[0] == '-') {
                 output_message(STRING_MISSING_INTEGER);
                 break;
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 8232b75..72077d8 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -279,8 +279,8 @@ static void test_add(void)
     ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
     ok(type == REG_DWORD, "got wrong type %d, expected %d\n", type, REG_DWORD);
     ok(size == sizeof(DWORD), "got wrong size %d, expected %d\n", size, (int)sizeof(DWORD));
-    todo_wine ok(dword == 123 || broken(dword == 0123 /* WinXP */),
-                 "got wrong data %d, expected %d\n", dword, 123);
+    ok(dword == 123 || broken(dword == 0123 /* WinXP */),
+       "got wrong data %d, expected %d\n", dword, 123);
 
     run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword7 /t reg_dword /d 0xabcdefg /f", &r);
     ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-- 
1.9.1




More information about the wine-patches mailing list