[PATCH 2/3] reg: Fail if access is denied when adding registry data

Hugh McMaster hugh.mcmaster at outlook.com
Mon May 3 08:20:36 CDT 2021


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/reg/add.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/programs/reg/add.c b/programs/reg/add.c
index 897c6f60621..258e3e8cb25 100644
--- a/programs/reg/add.c
+++ b/programs/reg/add.c
@@ -156,6 +156,7 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
     HKEY hkey;
     DWORD data_type, data_size;
     BYTE *reg_data = NULL;
+    LONG rc;
 
     if (RegCreateKeyExW(root, path, 0, NULL, REG_OPTION_NON_VOLATILE,
                         KEY_READ|KEY_WRITE, NULL, &hkey, NULL))
@@ -199,10 +200,17 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
         return 1;
     }
 
-    RegSetValueExW(hkey, value_name, 0, data_type, reg_data, data_size);
-    free(reg_data);
+    rc = RegSetValueExW(hkey, value_name, 0, data_type, reg_data, data_size);
 
+    free(reg_data);
     RegCloseKey(hkey);
+
+    if (rc)
+    {
+        output_message(STRING_ACCESS_DENIED);
+        return 1;
+    }
+
     output_message(STRING_SUCCESS);
 
     return 0;
-- 
2.31.1




More information about the wine-devel mailing list