Bruno Jesus : regedit: Allow importing strings with escaped NULL.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Oct 29 07:36:58 CDT 2014
Module: wine
Branch: master
Commit: c35bca6561a0150425a1838d4677d202cad65da5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c35bca6561a0150425a1838d4677d202cad65da5
Author: Bruno Jesus <00cpxxx at gmail.com>
Date: Wed Oct 29 00:30:13 2014 -0200
regedit: Allow importing strings with escaped NULL.
---
programs/regedit/regproc.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index d07fdc7..9d96287 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -255,7 +255,7 @@ static DWORD getDataType(LPWSTR *lpValue, DWORD* parse_type)
/******************************************************************************
* Replaces escape sequences with the characters.
*/
-static void REGPROC_unescape_string(WCHAR* str)
+static int REGPROC_unescape_string(WCHAR* str)
{
int str_idx = 0; /* current character under analysis */
int val_idx = 0; /* the last character of the unescaped string */
@@ -267,6 +267,9 @@ static void REGPROC_unescape_string(WCHAR* str)
case 'n':
str[val_idx] = '\n';
break;
+ case '0':
+ str[val_idx] = '\0';
+ break;
case '\\':
case '"':
str[val_idx] = str[str_idx];
@@ -282,6 +285,7 @@ static void REGPROC_unescape_string(WCHAR* str)
}
}
str[val_idx] = '\0';
+ return val_idx;
}
static BOOL parseKeyName(LPWSTR lpKeyName, HKEY *hKey, LPWSTR *lpKeyPath)
@@ -364,19 +368,10 @@ static LONG setValue(WCHAR* val_name, WCHAR* val_data, BOOL is_unicode)
if (dwParseType == REG_SZ) /* no conversion for string */
{
- REGPROC_unescape_string(val_data);
- /* Compute dwLen after REGPROC_unescape_string because it may
- * have changed the string length and we don't want to store
- * the extra garbage in the registry.
- */
- dwLen = lstrlenW(val_data);
- if(val_data[dwLen-1] != '"')
+ dwLen = REGPROC_unescape_string(val_data);
+ if(!dwLen || val_data[dwLen-1] != '"')
return ERROR_INVALID_DATA;
- if (dwLen>0 && val_data[dwLen-1]=='"')
- {
- dwLen--;
- val_data[dwLen]='\0';
- }
+ val_data[dwLen-1] = '\0'; /* remove last quotes */
lpbData = (BYTE*) val_data;
dwLen++; /* include terminating null */
dwLen = dwLen * sizeof(WCHAR); /* size is in bytes */
More information about the wine-cvs
mailing list