advapi32: Write back partial results in RegQueryInfoKeyA.

This commit is contained in:
Thomas Faber 2015-05-19 10:05:01 -04:00 committed by Alexandre Julliard
parent 87b6d42c12
commit 817d903cb9
2 changed files with 15 additions and 15 deletions

View File

@ -1049,18 +1049,18 @@ LSTATUS WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDW
if (status) goto done;
RtlUnicodeToMultiByteSize( &len, (WCHAR *)(buf_ptr + info->ClassOffset), info->ClassLength);
if (class_len)
len = 0;
if (class && class_len) len = *class_len;
RtlUnicodeToMultiByteN( class, len, class_len,
(WCHAR *)(buf_ptr + info->ClassOffset), info->ClassLength );
if (len)
{
if (*class_len == 0) class = NULL;
if (class && len + 1 > *class_len) status = STATUS_BUFFER_OVERFLOW;
*class_len = len;
}
if (class && !status)
{
RtlUnicodeToMultiByteN( class, len, NULL, (WCHAR *)(buf_ptr + info->ClassOffset),
info->ClassLength );
class[len] = 0;
class[len - 1] = 0;
if (*class_len + 1 > len)
{
status = STATUS_BUFFER_OVERFLOW;
*class_len -= 1;
}
}
}
else status = STATUS_SUCCESS;

View File

@ -1815,10 +1815,10 @@ static void test_reg_query_info(void)
classlen = 1;
ret = RegQueryInfoKeyA(subkey, classbuffer, &classlen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
ok(ret == ERROR_MORE_DATA, "ret = %d\n", ret);
todo_wine ok(classlen == 0, "classlen = %u\n", classlen);
ok(classlen == 0, "classlen = %u\n", classlen);
memset(expectbuffer, 0x55, sizeof(expectbuffer));
expectbuffer[0] = 0;
todo_wine ok(!memcmp(classbuffer, expectbuffer, sizeof(classbuffer)), "classbuffer was modified\n");
ok(!memcmp(classbuffer, expectbuffer, sizeof(classbuffer)), "classbuffer was modified\n");
memset(classbufferW, 0x55, sizeof(classbufferW));
classlen = 1;
@ -1834,12 +1834,12 @@ static void test_reg_query_info(void)
classlen = sizeof(subkey_class) - 1;
ret = RegQueryInfoKeyA(subkey, classbuffer, &classlen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
ok(ret == ERROR_MORE_DATA, "ret = %d\n", ret);
todo_wine ok(classlen == sizeof(subkey_class) - 2, "classlen = %u\n", classlen);
ok(classlen == sizeof(subkey_class) - 2, "classlen = %u\n", classlen);
memset(expectbuffer, 0x55, sizeof(expectbuffer));
strcpy(expectbuffer, subkey_class);
expectbuffer[sizeof(subkey_class) - 2] = 0;
expectbuffer[sizeof(subkey_class) - 1] = 0x55;
todo_wine ok(!memcmp(classbuffer, expectbuffer, sizeof(classbuffer)),
ok(!memcmp(classbuffer, expectbuffer, sizeof(classbuffer)),
"classbuffer = %.*s, expected %s\n",
(int)sizeof(classbuffer), classbuffer, expectbuffer);