From d816192eccbe48b26a345e3887aeb8b19da3aa8f Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 14 May 2013 14:01:08 +0200 Subject: [PATCH] wmiutils: Accept namespaces without a leading slash. --- dlls/wmiutils/path.c | 17 +++++++++++++++++ dlls/wmiutils/tests/path.c | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c index dcade4638c9..988d2e635f0 100644 --- a/dlls/wmiutils/path.c +++ b/dlls/wmiutils/path.c @@ -420,6 +420,11 @@ static HRESULT parse_text( struct path *path, ULONG mode, const WCHAR *text ) path->flags |= WBEMPATH_INFO_PATH_HAD_SERVER; } p = q; + if (*q && *q != '\\' && *q != '/' && *q != ':') + { + path->num_namespaces = 1; + q++; + } while (*q && *q != ':') { if (*q == '\\' || *q == '/') path->num_namespaces++; @@ -432,6 +437,18 @@ static HRESULT parse_text( struct path *path, ULONG mode, const WCHAR *text ) i = 0; q = p; + if (*q && *q != '\\' && *q != '/' && *q != ':') + { + p = q; + while (*p && *p != '\\' && *p != '/' && *p != ':') p++; + len = p - q; + if (!(path->namespaces[i] = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto done; + memcpy( path->namespaces[i], q, len * sizeof(WCHAR) ); + path->namespaces[i][len] = 0; + path->len_namespaces[i] = len; + q = p; + i++; + } while (*q && *q != ':') { if (*q == '\\' || *q == '/') diff --git a/dlls/wmiutils/tests/path.c b/dlls/wmiutils/tests/path.c index 935ee52f509..54c0e9a239b 100644 --- a/dlls/wmiutils/tests/path.c +++ b/dlls/wmiutils/tests/path.c @@ -122,7 +122,8 @@ static void test_IWbemPath_SetText(void) { path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK }, { path9, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK }, { path10, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, 1 }, - { path11, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK } + { path11, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK }, + { path15, WBEMPATH_CREATE_ACCEPT_ALL, S_OK } }; IWbemPath *path; HRESULT hr; @@ -167,6 +168,8 @@ static void test_IWbemPath_GetText(void) static const WCHAR expected2W[] = {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k','.', 'D','e','v','i','c','e','I','d','=','"','C',':','"',0}; + static const WCHAR expected3W[] = + {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0}; WCHAR buf[128]; ULONG len, count; IWbemPath *path; @@ -306,6 +309,16 @@ static void test_IWbemPath_GetText(void) ok( !lstrcmpW( buf, expected2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) ); ok( len == lstrlenW( expected2W ) + 1, "unexpected length %u\n", len ); + hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path15 ); + ok( hr == S_OK, "got %08x\n", hr ); + + len = sizeof(buf)/sizeof(buf[0]); + memset( buf, 0x55, sizeof(buf) ); + hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( !lstrcmpW( buf, expected3W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) ); + ok( len == lstrlenW( expected3W ) + 1, "unexpected length %u\n", len ); + hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path18 ); ok( hr == S_OK, "got %08x\n", hr );