Commit c6615832 authored by Alexandre Julliard's avatar Alexandre Julliard

Always return success instead of overflow if caller didn't specify a

buffer.
parent 1da4707f
......@@ -447,6 +447,7 @@ DWORD WINAPI RegQueryInfoKeyW( HKEY hkey, LPWSTR class, LPDWORD class_len, LPDWO
return ERROR_INVALID_PARAMETER;
status = NtQueryKey( hkey, KeyFullInformation, buffer, sizeof(buffer), &total_size );
if (status && status != STATUS_BUFFER_OVERFLOW) goto done;
if (class)
{
......@@ -460,8 +461,8 @@ DWORD WINAPI RegQueryInfoKeyW( HKEY hkey, LPWSTR class, LPDWORD class_len, LPDWO
status = NtQueryKey( hkey, KeyFullInformation, buf_ptr, total_size, &total_size );
}
if (!status)
{
if (status) goto done;
if (class_len && (info->ClassLength/sizeof(WCHAR) + 1 > *class_len))
{
status = STATUS_BUFFER_OVERFLOW;
......@@ -472,10 +473,8 @@ DWORD WINAPI RegQueryInfoKeyW( HKEY hkey, LPWSTR class, LPDWORD class_len, LPDWO
class[info->ClassLength/sizeof(WCHAR)] = 0;
}
}
}
else status = STATUS_SUCCESS;
if (!status || status == STATUS_BUFFER_OVERFLOW)
{
if (class_len) *class_len = info->ClassLength / sizeof(WCHAR);
if (subkeys) *subkeys = info->SubKeys;
if (max_subkey) *max_subkey = info->MaxNameLen;
......@@ -484,8 +483,8 @@ DWORD WINAPI RegQueryInfoKeyW( HKEY hkey, LPWSTR class, LPDWORD class_len, LPDWO
if (max_value) *max_value = info->MaxValueNameLen;
if (max_data) *max_data = info->MaxValueDataLen;
if (modif) *modif = info->LastWriteTime;
}
done:
if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr );
return RtlNtStatusToDosError( status );
}
......@@ -502,7 +501,7 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
NTSTATUS status;
char buffer[256], *buf_ptr = buffer;
KEY_FULL_INFORMATION *info = (KEY_FULL_INFORMATION *)buffer;
DWORD total_size;
DWORD total_size, len;
TRACE( "(0x%x,%p,%ld,%p,%p,%p,%p,%p,%p,%p,%p)\n", hkey, class, class_len ? *class_len : 0,
reserved, subkeys, max_subkey, values, max_value, max_data, security, modif );
......@@ -511,6 +510,7 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
return ERROR_INVALID_PARAMETER;
status = NtQueryKey( hkey, KeyFullInformation, buffer, sizeof(buffer), &total_size );
if (status && status != STATUS_BUFFER_OVERFLOW) goto done;
if (class || class_len)
{
......@@ -524,9 +524,9 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
status = NtQueryKey( hkey, KeyFullInformation, buf_ptr, total_size, &total_size );
}
if (!status)
{
DWORD len = WideCharToMultiByte( CP_ACP, 0,
if (status) goto done;
len = WideCharToMultiByte( CP_ACP, 0,
(WCHAR *)(buf_ptr + info->ClassOffset),
info->ClassLength/sizeof(WCHAR),
NULL, 0, NULL, NULL );
......@@ -544,10 +544,8 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
class[len] = 0;
}
}
}
else status = STATUS_SUCCESS;
if (!status || status == STATUS_BUFFER_OVERFLOW)
{
if (subkeys) *subkeys = info->SubKeys;
if (max_subkey) *max_subkey = info->MaxNameLen;
if (max_class) *max_class = info->MaxClassLen;
......@@ -555,8 +553,8 @@ DWORD WINAPI RegQueryInfoKeyA( HKEY hkey, LPSTR class, LPDWORD class_len, LPDWOR
if (max_value) *max_value = info->MaxValueNameLen;
if (max_data) *max_data = info->MaxValueDataLen;
if (modif) *modif = info->LastWriteTime;
}
done:
if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr );
return RtlNtStatusToDosError( status );
}
......@@ -821,6 +819,7 @@ DWORD WINAPI RegQueryValueExW( HKEY hkey, LPCWSTR name, LPDWORD reserved, LPDWOR
}
else if (status != STATUS_BUFFER_OVERFLOW) goto done;
}
else status = STATUS_SUCCESS;
if (type) *type = info->Type;
if (count) *count = total_size - info_size;
......@@ -880,8 +879,8 @@ DWORD WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWORD
buf_ptr, total_size, &total_size );
}
if (!status)
{
if (status) goto done;
if (is_string(info->Type))
{
DWORD len = WideCharToMultiByte( CP_ACP, 0, (WCHAR *)(buf_ptr + info_size),
......@@ -908,8 +907,7 @@ DWORD WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWORD
else memcpy( data, buf_ptr + info_size, total_size - info_size );
}
}
else if (status != STATUS_BUFFER_OVERFLOW) goto done;
}
else status = STATUS_SUCCESS;
if (type) *type = info->Type;
if (count) *count = total_size - info_size;
......@@ -1056,6 +1054,7 @@ DWORD WINAPI RegEnumValueW( HKEY hkey, DWORD index, LPWSTR value, LPDWORD val_co
}
}
}
else status = STATUS_SUCCESS;
if (type) *type = info->Type;
if (count) *count = info->DataLength;
......@@ -1151,6 +1150,7 @@ DWORD WINAPI RegEnumValueA( HKEY hkey, DWORD index, LPSTR value, LPDWORD val_cou
else memcpy( data, buf_ptr + info->DataOffset, total_size - info->DataOffset );
}
}
else status = STATUS_SUCCESS;
if (type) *type = info->Type;
if (count) *count = info->DataLength;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment