wbemprox: Return WBEM_E_INVALID_CLASS from create_view() if namespace is empty.

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2021-09-13 17:13:28 +03:00 committed by Alexandre Julliard
parent 73d8cc3281
commit 73aab21de6
2 changed files with 29 additions and 0 deletions

View File

@ -62,6 +62,7 @@ HRESULT create_view( enum view_type type, enum wbm_namespace ns, const WCHAR *pa
heap_free( view ); heap_free( view );
return hr; return hr;
} }
else if (!table && ns == WBEMPROX_NAMESPACE_LAST) return WBEM_E_INVALID_CLASS;
view->proplist = proplist; view->proplist = proplist;
view->cond = cond; view->cond = cond;
break; break;

View File

@ -2061,6 +2061,33 @@ static void test_Win32_LogicalDisk( IWbemServices *services )
SysFreeString( wql ); SysFreeString( wql );
} }
static void test_empty_namespace( IWbemLocator *locator )
{
BSTR path = SysAllocString( L"ROOT" );
BSTR wql = SysAllocString( L"wql" );
IEnumWbemClassObject *result;
IWbemServices *services;
BSTR query;
HRESULT hr;
hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
ok( hr == S_OK, "failed to get IWbemServices interface %08x\n", hr );
query = SysAllocString( L"SELECT * FROM __ASSOCIATORS" );
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
ok( hr == WBEM_E_INVALID_CLASS, "Query failed: %08x\n", hr );
SysFreeString( query );
query = SysAllocString( L"SELECT * FROM Win32_OperatingSystem" );
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
ok( hr == WBEM_E_INVALID_CLASS, "got %08x\n", hr );
SysFreeString( query );
SysFreeString( wql );
SysFreeString( path );
IWbemServices_Release( services );
}
START_TEST(query) START_TEST(query)
{ {
BSTR path = SysAllocString( L"ROOT\\CIMV2" ); BSTR path = SysAllocString( L"ROOT\\CIMV2" );
@ -2138,6 +2165,7 @@ START_TEST(query)
test_Win32_VideoController( services ); test_Win32_VideoController( services );
test_Win32_WinSAT( services ); test_Win32_WinSAT( services );
test_SystemRestore( services ); test_SystemRestore( services );
test_empty_namespace( locator );
SysFreeString( path ); SysFreeString( path );
IWbemServices_Release( services ); IWbemServices_Release( services );