[4/8] regedit: If the data for a given value is in an unknown
format, then print an error and don't modify the value.
Francois Gouget
fgouget at codeweavers.com
Thu Jun 14 04:43:58 CDT 2007
Note that '"foo"=' is not valid.
---
This fixes a warning about dwParseType being potentially used
uninitialised that was revealed when I made the functions static
(somehow gcc was not able to detect it before).
programs/regedit/regproc.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 3f55427..0840c46 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -169,7 +169,8 @@ static DWORD getDataType(LPSTR *lpValue, DWORD* parse_type)
}
return type;
}
- return (**lpValue=='\0'?REG_SZ:REG_NONE);
+ *parse_type=REG_NONE;
+ return REG_NONE;
}
/******************************************************************************
@@ -230,7 +231,7 @@ static HRESULT setValue(LPSTR val_name, LPSTR val_data)
/* Get the data type stored into the value field */
dwDataType = getDataType(&val_data, &dwParseType);
- if ( dwParseType == REG_SZ) /* no conversion for string */
+ if (dwParseType == REG_SZ) /* no conversion for string */
{
REGPROC_unescape_string(val_data);
/* Compute dwLen after REGPROC_unescape_string because it may
@@ -244,11 +245,13 @@ static HRESULT setValue(LPSTR val_name, LPSTR val_data)
val_data[dwLen]='\0';
}
lpbData = (BYTE*) val_data;
- } else if (dwParseType == REG_DWORD) /* Convert the dword types */
+ }
+ else if (dwParseType == REG_DWORD) /* Convert the dword types */
{
dwLen = convertHexToDWord(val_data, convert);
lpbData = convert;
- } else /* Convert the hexadecimal types */
+ }
+ else if (dwParseType == REG_BINARY) /* Convert the binary data */
{
int b_len = strlen (val_data)+2/3;
if (b_len > KEY_MAX_LEN) {
@@ -261,6 +264,11 @@ static HRESULT setValue(LPSTR val_name, LPSTR val_data)
lpbData = convert;
}
}
+ else /* unknown format */
+ {
+ fprintf(stderr,"%s: ERROR, unknown data format\n", getAppName());
+ return ERROR_INVALID_DATA;
+ }
hRes = RegSetValueEx(
currentKeyHandle,
--
1.4.4.4
More information about the wine-patches
mailing list