[PATCH] reg: Fixed 2 functionality bugs in REG DELETE (Coverity)
Marcus Meissner
marcus at jet.franken.de
Sun Dec 6 15:45:48 CST 2009
Hi,
Coverity spotted some dead code, but the bug is not in dead code ;)
- The REG DELETE sub tree deletion only happens when
no /v* options are given. So check for all 3 seperate modes,
not just for 1.
- REG DELETE /va used an uninitialized value_name,
but allocated szValue for this purpose. The crash never happened,
because the above bug triggered.
Ciao, Marcus
---
programs/reg/reg.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index f0a8f8b..07dbdbf 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -255,7 +255,8 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
/* FIXME: Prompt for delete */
}
- if (!value_name)
+ /* Delete subtree only if no /v* option is given */
+ if (!value_name && !value_empty && !value_all)
{
if (RegDeleteTreeW(root,p)!=ERROR_SUCCESS)
{
@@ -293,10 +294,10 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
while (1)
{
count = maxValue;
- rc = RegEnumValueW(subkey, 0, value_name, &count, NULL, NULL, NULL, NULL);
+ rc = RegEnumValueW(subkey, 0, szValue, &count, NULL, NULL, NULL, NULL);
if (rc == ERROR_SUCCESS)
{
- rc = RegDeleteValueW(subkey,value_name);
+ rc = RegDeleteValueW(subkey, szValue);
if (rc != ERROR_SUCCESS)
break;
}
--
1.5.6
More information about the wine-patches
mailing list