advapi32: Fix null termination in RegQueryInfoKeyA.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
fda55a3fdf
commit
303daeef58
|
@ -1162,12 +1162,12 @@ LSTATUS WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDW
|
|||
(WCHAR *)(buf_ptr + info->ClassOffset), info->ClassLength );
|
||||
if (len)
|
||||
{
|
||||
class[len - 1] = 0;
|
||||
if (*class_len + 1 > len)
|
||||
{
|
||||
status = STATUS_BUFFER_OVERFLOW;
|
||||
*class_len -= 1;
|
||||
}
|
||||
class[*class_len] = 0;
|
||||
}
|
||||
}
|
||||
else status = STATUS_SUCCESS;
|
||||
|
|
|
@ -1987,6 +1987,17 @@ static void test_reg_query_info(void)
|
|||
"classbuffer = \"%.*s\", expected %s\n",
|
||||
(int)sizeof(classbuffer), classbuffer, expectbuffer);
|
||||
|
||||
memset(classbuffer, 0x55, sizeof(classbuffer));
|
||||
classlen = 0xdeadbeef;
|
||||
ret = RegQueryInfoKeyA(subkey, classbuffer, &classlen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
|
||||
ok(classlen == sizeof(subkey_class) - 1, "classlen = %u\n", classlen);
|
||||
memset(expectbuffer, 0x55, sizeof(expectbuffer));
|
||||
strcpy(expectbuffer, subkey_class);
|
||||
ok(!memcmp(classbuffer, expectbuffer, sizeof(classbuffer)),
|
||||
"classbuffer = \"%.*s\", expected %s\n",
|
||||
(int)sizeof(classbuffer), classbuffer, expectbuffer);
|
||||
|
||||
memset(classbufferW, 0x55, sizeof(classbufferW));
|
||||
classlen = sizeof(subkey_class);
|
||||
ret = RegQueryInfoKeyW(subkey, classbufferW, &classlen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
@ -1998,6 +2009,17 @@ static void test_reg_query_info(void)
|
|||
"classbufferW = %s, expected %s\n",
|
||||
wine_dbgstr_wn(classbufferW, sizeof(classbufferW) / sizeof(WCHAR)), wine_dbgstr_w(expectbufferW));
|
||||
|
||||
memset(classbufferW, 0x55, sizeof(classbufferW));
|
||||
classlen = 0xdeadbeef;
|
||||
ret = RegQueryInfoKeyW(subkey, classbufferW, &classlen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
|
||||
ok(classlen == sizeof(subkey_class) - 1, "classlen = %u\n", classlen);
|
||||
memset(expectbufferW, 0x55, sizeof(expectbufferW));
|
||||
lstrcpyW(expectbufferW, subkey_classW);
|
||||
ok(!memcmp(classbufferW, expectbufferW, sizeof(classbufferW)),
|
||||
"classbufferW = %s, expected %s\n",
|
||||
wine_dbgstr_wn(classbufferW, sizeof(classbufferW) / sizeof(WCHAR)), wine_dbgstr_w(expectbufferW));
|
||||
|
||||
RegDeleteKeyA(subsubkey, "");
|
||||
RegCloseKey(subsubkey);
|
||||
RegDeleteKeyA(subkey, "");
|
||||
|
|
Loading…
Reference in New Issue