1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-12-08 23:33:07 +01:00

Land #128 : Fix unicode REG_EXPAND_SZ handling

Fixes #127
This commit is contained in:
OJ 2016-09-30 14:39:36 +10:00
commit 4ba1d16acc
No known key found for this signature in database
GPG Key ID: D5DC61FB93260597

View File

@ -459,11 +459,15 @@ static void set_value(Remote *remote, Packet *packet, HKEY hkey)
} else {
// Now let's rock this shit!
void *buf;
size_t len = valueData.header.length;
if (valueType == REG_SZ) {
size_t len;
switch (valueType) {
case REG_SZ:
case REG_EXPAND_SZ:
buf = utf8_to_wchar(valueData.buffer);
len = (wcslen(buf) + 1) * sizeof(wchar_t);
} else {
break;
default:
len = valueData.header.length;
buf = valueData.buffer;
}
result = RegSetValueExW(hkey, valueName, 0, valueType, buf, (DWORD)len);
@ -561,6 +565,7 @@ static void query_value(Remote *remote, Packet *packet, HKEY hkey)
switch (valueType) {
case REG_SZ:
case REG_EXPAND_SZ:
tmp = wchar_to_utf8((wchar_t *)valueData);
if (tmp) {
packet_add_tlv_string(response, TLV_TYPE_VALUE_DATA, tmp);