From 73aab21de686e8a6bf663fc05563a745574b1a85 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 13 Sep 2021 17:13:28 +0300 Subject: [PATCH] wbemprox: Return WBEM_E_INVALID_CLASS from create_view() if namespace is empty. Signed-off-by: Paul Gofman Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/wbemprox/query.c | 1 + dlls/wbemprox/tests/query.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c index 108e3b4ad81..77ed27e105d 100644 --- a/dlls/wbemprox/query.c +++ b/dlls/wbemprox/query.c @@ -62,6 +62,7 @@ HRESULT create_view( enum view_type type, enum wbm_namespace ns, const WCHAR *pa heap_free( view ); return hr; } + else if (!table && ns == WBEMPROX_NAMESPACE_LAST) return WBEM_E_INVALID_CLASS; view->proplist = proplist; view->cond = cond; break; diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index 784ebd3503d..69bb8e7977e 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -2061,6 +2061,33 @@ static void test_Win32_LogicalDisk( IWbemServices *services ) 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) { BSTR path = SysAllocString( L"ROOT\\CIMV2" ); @@ -2138,6 +2165,7 @@ START_TEST(query) test_Win32_VideoController( services ); test_Win32_WinSAT( services ); test_SystemRestore( services ); + test_empty_namespace( locator ); SysFreeString( path ); IWbemServices_Release( services );