wmiutils: Fix buffer size query in IWbemPath::GetText.
This commit is contained in:
parent
67c57b216c
commit
f776b64fa6
|
@ -237,10 +237,10 @@ static WCHAR *build_server( struct path *path, int *len )
|
||||||
WCHAR *ret, *p;
|
WCHAR *ret, *p;
|
||||||
|
|
||||||
*len = 0;
|
*len = 0;
|
||||||
if (path->server) *len += 2 + path->len_server;
|
if (path->len_server) *len += 2 + path->len_server;
|
||||||
else *len += 4;
|
else *len += 4;
|
||||||
if (!(p = ret = heap_alloc( (*len + 1) * sizeof(WCHAR) ))) return NULL;
|
if (!(p = ret = heap_alloc( (*len + 1) * sizeof(WCHAR) ))) return NULL;
|
||||||
if (path->server)
|
if (path->len_server)
|
||||||
{
|
{
|
||||||
p[0] = p[1] = '\\';
|
p[0] = p[1] = '\\';
|
||||||
strcpyW( p + 2, path->server );
|
strcpyW( p + 2, path->server );
|
||||||
|
@ -265,14 +265,14 @@ static WCHAR *build_path( struct path *path, LONG flags, int *len )
|
||||||
if (!namespace) return NULL;
|
if (!namespace) return NULL;
|
||||||
|
|
||||||
*len = len_namespace;
|
*len = len_namespace;
|
||||||
if (path->class) *len += 1 + path->len_class;
|
if (path->len_class) *len += 1 + path->len_class;
|
||||||
if (!(ret = heap_alloc( (*len + 1) * sizeof(WCHAR) )))
|
if (!(ret = heap_alloc( (*len + 1) * sizeof(WCHAR) )))
|
||||||
{
|
{
|
||||||
heap_free( namespace );
|
heap_free( namespace );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpyW( ret, namespace );
|
strcpyW( ret, namespace );
|
||||||
if (path->class)
|
if (path->len_class)
|
||||||
{
|
{
|
||||||
ret[len_namespace] = ':';
|
ret[len_namespace] = ':';
|
||||||
strcpyW( ret + len_namespace + 1, path->class );
|
strcpyW( ret + len_namespace + 1, path->class );
|
||||||
|
@ -282,7 +282,7 @@ static WCHAR *build_path( struct path *path, LONG flags, int *len )
|
||||||
|
|
||||||
}
|
}
|
||||||
case WBEMPATH_GET_RELATIVE_ONLY:
|
case WBEMPATH_GET_RELATIVE_ONLY:
|
||||||
if (!path->class)
|
if (!path->len_class)
|
||||||
{
|
{
|
||||||
*len = 0;
|
*len = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -303,7 +303,7 @@ static WCHAR *build_path( struct path *path, LONG flags, int *len )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*len = len_namespace + len_server;
|
*len = len_namespace + len_server;
|
||||||
if (path->class) *len += 1 + path->len_class;
|
if (path->len_class) *len += 1 + path->len_class;
|
||||||
if (!(p = ret = heap_alloc( (*len + 1) * sizeof(WCHAR) )))
|
if (!(p = ret = heap_alloc( (*len + 1) * sizeof(WCHAR) )))
|
||||||
{
|
{
|
||||||
heap_free( namespace );
|
heap_free( namespace );
|
||||||
|
@ -314,7 +314,7 @@ static WCHAR *build_path( struct path *path, LONG flags, int *len )
|
||||||
p += len_server;
|
p += len_server;
|
||||||
strcpyW( p, namespace );
|
strcpyW( p, namespace );
|
||||||
p += len_namespace;
|
p += len_namespace;
|
||||||
if (path->class)
|
if (path->len_class)
|
||||||
{
|
{
|
||||||
*p = ':';
|
*p = ':';
|
||||||
strcpyW( p + 1, path->class );
|
strcpyW( p + 1, path->class );
|
||||||
|
@ -353,7 +353,7 @@ static WCHAR *build_path( struct path *path, LONG flags, int *len )
|
||||||
return build_namespace( path, len );
|
return build_namespace( path, len );
|
||||||
|
|
||||||
case WBEMPATH_GET_ORIGINAL:
|
case WBEMPATH_GET_ORIGINAL:
|
||||||
if (!path->text)
|
if (!path->len_text)
|
||||||
{
|
{
|
||||||
*len = 0;
|
*len = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -379,7 +379,7 @@ static HRESULT WINAPI path_GetText(
|
||||||
|
|
||||||
TRACE("%p, 0x%x, %p, %p\n", iface, lFlags, puBufferLength, pszText);
|
TRACE("%p, 0x%x, %p, %p\n", iface, lFlags, puBufferLength, pszText);
|
||||||
|
|
||||||
if (!puBufferLength || !pszText) return WBEM_E_INVALID_PARAMETER;
|
if (!puBufferLength) return WBEM_E_INVALID_PARAMETER;
|
||||||
|
|
||||||
str = build_path( path, lFlags, &len );
|
str = build_path( path, lFlags, &len );
|
||||||
|
|
||||||
|
@ -388,12 +388,16 @@ static HRESULT WINAPI path_GetText(
|
||||||
*puBufferLength = len + 1;
|
*puBufferLength = len + 1;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
if (pszText)
|
if (!pszText)
|
||||||
{
|
{
|
||||||
|
heap_free( str );
|
||||||
|
return WBEM_E_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
if (str) strcpyW( pszText, str );
|
if (str) strcpyW( pszText, str );
|
||||||
else pszText[0] = 0;
|
else pszText[0] = 0;
|
||||||
}
|
|
||||||
*puBufferLength = len + 1;
|
*puBufferLength = len + 1;
|
||||||
|
|
||||||
|
TRACE("<-- %s\n", debugstr_w(pszText));
|
||||||
heap_free( str );
|
heap_free( str );
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue