mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 05:58:13 +00:00
[WINESYNC] reg: Allow the 'reg_data' pointer to be NULL.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id e2dfb0aff42153f2c1a25e8c9b37ad10409aca36 by Hugh McMaster <hugh.mcmaster@outlook.com>
This commit is contained in:
parent
a5469189ad
commit
d8277eee6f
2 changed files with 30 additions and 24 deletions
|
@ -48,10 +48,10 @@ static inline BYTE hexchar_to_byte(WCHAR ch)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BYTE *get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWORD *size_bytes)
|
static BOOL get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator,
|
||||||
|
BYTE **data_bytes, DWORD *size_bytes)
|
||||||
{
|
{
|
||||||
static const WCHAR empty;
|
static const WCHAR empty;
|
||||||
LPBYTE out_data = NULL;
|
|
||||||
|
|
||||||
*size_bytes = 0;
|
*size_bytes = 0;
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ static BYTE *get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWO
|
||||||
case REG_EXPAND_SZ:
|
case REG_EXPAND_SZ:
|
||||||
{
|
{
|
||||||
*size_bytes = (lstrlenW(data) + 1) * sizeof(WCHAR);
|
*size_bytes = (lstrlenW(data) + 1) * sizeof(WCHAR);
|
||||||
out_data = malloc(*size_bytes);
|
*data_bytes = malloc(*size_bytes);
|
||||||
lstrcpyW((LPWSTR)out_data,data);
|
lstrcpyW((WCHAR *)*data_bytes, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REG_DWORD:
|
case REG_DWORD:
|
||||||
|
@ -77,41 +77,46 @@ static BYTE *get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWO
|
||||||
val = wcstoul(data, &rest, (towlower(data[1]) == 'x') ? 16 : 10);
|
val = wcstoul(data, &rest, (towlower(data[1]) == 'x') ? 16 : 10);
|
||||||
if (*rest || data[0] == '-' || (val == ~0u && errno == ERANGE)) {
|
if (*rest || data[0] == '-' || (val == ~0u && errno == ERANGE)) {
|
||||||
output_message(STRING_MISSING_INTEGER);
|
output_message(STRING_MISSING_INTEGER);
|
||||||
break;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*size_bytes = sizeof(DWORD);
|
*size_bytes = sizeof(DWORD);
|
||||||
out_data = malloc(*size_bytes);
|
*data_bytes = malloc(*size_bytes);
|
||||||
((LPDWORD)out_data)[0] = val;
|
*(DWORD *)*data_bytes = val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REG_BINARY:
|
case REG_BINARY:
|
||||||
{
|
{
|
||||||
BYTE hex0, hex1;
|
BYTE hex0, hex1, *ptr;
|
||||||
int i = 0, destByteIndex = 0, datalen = lstrlenW(data);
|
int i = 0, destByteIndex = 0, datalen = lstrlenW(data);
|
||||||
|
|
||||||
*size_bytes = ((datalen + datalen % 2) / 2) * sizeof(BYTE);
|
*size_bytes = ((datalen + datalen % 2) / 2) * sizeof(BYTE);
|
||||||
out_data = malloc(*size_bytes);
|
*data_bytes = malloc(*size_bytes);
|
||||||
if(datalen % 2)
|
|
||||||
|
if (datalen % 2)
|
||||||
{
|
{
|
||||||
hex1 = hexchar_to_byte(data[i++]);
|
hex1 = hexchar_to_byte(data[i++]);
|
||||||
if(hex1 == 0xFF)
|
if (hex1 == 0xFF)
|
||||||
goto no_hex_data;
|
goto no_hex_data;
|
||||||
out_data[destByteIndex++] = hex1;
|
*data_bytes[destByteIndex++] = hex1;
|
||||||
}
|
}
|
||||||
for(;i + 1 < datalen;i += 2)
|
|
||||||
|
ptr = *data_bytes;
|
||||||
|
|
||||||
|
for (; i + 1 < datalen; i += 2)
|
||||||
{
|
{
|
||||||
hex0 = hexchar_to_byte(data[i]);
|
hex0 = hexchar_to_byte(data[i]);
|
||||||
hex1 = hexchar_to_byte(data[i + 1]);
|
hex1 = hexchar_to_byte(data[i + 1]);
|
||||||
if(hex0 == 0xFF || hex1 == 0xFF)
|
if (hex0 == 0xFF || hex1 == 0xFF)
|
||||||
goto no_hex_data;
|
goto no_hex_data;
|
||||||
out_data[destByteIndex++] = (hex0 << 4) | hex1;
|
ptr[destByteIndex++] = (hex0 << 4) | hex1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
no_hex_data:
|
no_hex_data:
|
||||||
/* cleanup, print error */
|
free(*data_bytes);
|
||||||
free(out_data);
|
*data_bytes = NULL;
|
||||||
output_message(STRING_MISSING_HEXDATA);
|
output_message(STRING_MISSING_HEXDATA);
|
||||||
out_data = NULL;
|
return FALSE;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case REG_MULTI_SZ:
|
case REG_MULTI_SZ:
|
||||||
{
|
{
|
||||||
|
@ -134,20 +139,21 @@ static BYTE *get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWO
|
||||||
{
|
{
|
||||||
free(buffer);
|
free(buffer);
|
||||||
output_message(STRING_INVALID_STRING);
|
output_message(STRING_INVALID_STRING);
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer[destindex] = 0;
|
buffer[destindex] = 0;
|
||||||
if (destindex && buffer[destindex - 1])
|
if (destindex && buffer[destindex - 1])
|
||||||
buffer[++destindex] = 0;
|
buffer[++destindex] = 0;
|
||||||
*size_bytes = (destindex + 1) * sizeof(WCHAR);
|
*size_bytes = (destindex + 1) * sizeof(WCHAR);
|
||||||
return (BYTE *)buffer;
|
*data_bytes = (BYTE *)buffer;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
output_message(STRING_UNHANDLED_TYPE, reg_type, data);
|
output_message(STRING_UNHANDLED_TYPE, reg_type, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out_data;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
|
static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
|
||||||
|
@ -194,7 +200,7 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(reg_data = get_regdata(data, data_type, separator, &data_size)))
|
if (!get_regdata(data, data_type, separator, ®_data, &data_size))
|
||||||
{
|
{
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -4,4 +4,4 @@ directories:
|
||||||
files:
|
files:
|
||||||
programs/reg/resource.h: base/applications/cmdutils/reg/resource.h
|
programs/reg/resource.h: base/applications/cmdutils/reg/resource.h
|
||||||
tags:
|
tags:
|
||||||
wine: cf1e6d3f3fcb726062b957a973bb0a78b7e00eab
|
wine: e2dfb0aff42153f2c1a25e8c9b37ad10409aca36
|
||||||
|
|
Loading…
Reference in a new issue