fusion: Fix insufficient buffer size handling in IAssemblyName::GetDisplayName.
This commit is contained in:
parent
382b72d729
commit
2eda884bd7
|
@ -228,12 +228,10 @@ static HRESULT WINAPI IAssemblyNameImpl_GetDisplayName(IAssemblyName *iface,
|
|||
LPDWORD pccDisplayName,
|
||||
DWORD dwDisplayFlags)
|
||||
{
|
||||
IAssemblyNameImpl *name = impl_from_IAssemblyName(iface);
|
||||
WCHAR verstr[30];
|
||||
DWORD size;
|
||||
LPWSTR cultureval = 0;
|
||||
|
||||
static const WCHAR equals[] = {'=',0};
|
||||
IAssemblyNameImpl *name = impl_from_IAssemblyName(iface);
|
||||
WCHAR verstr[30], *cultureval = NULL;
|
||||
DWORD size;
|
||||
|
||||
TRACE("(%p, %p, %p, %d)\n", iface, szDisplayName,
|
||||
pccDisplayName, dwDisplayFlags);
|
||||
|
@ -243,9 +241,15 @@ static HRESULT WINAPI IAssemblyNameImpl_GetDisplayName(IAssemblyName *iface,
|
|||
if (!name->displayname || !*name->displayname)
|
||||
return FUSION_E_INVALID_NAME;
|
||||
|
||||
size = min(*pccDisplayName, lstrlenW(name->displayname) + 1);
|
||||
size = strlenW(name->displayname) + 1;
|
||||
|
||||
lstrcpynW(szDisplayName, name->displayname, size);
|
||||
if (*pccDisplayName < size)
|
||||
{
|
||||
*pccDisplayName = size;
|
||||
return E_NOT_SUFFICIENT_BUFFER;
|
||||
}
|
||||
|
||||
if (szDisplayName) strcpyW(szDisplayName, name->displayname);
|
||||
*pccDisplayName = size;
|
||||
|
||||
return S_OK;
|
||||
|
|
|
@ -508,6 +508,23 @@ static void test_CreateAssemblyNameObject(void)
|
|||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
ok(name != NULL, "Expected non-NULL name\n");
|
||||
|
||||
size = 0;
|
||||
hr = IAssemblyName_GetDisplayName(name, NULL, &size, 0);
|
||||
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got %08x\n", hr);
|
||||
ok(size == 5, "got %u\n", size);
|
||||
|
||||
size = 3;
|
||||
hr = IAssemblyName_GetDisplayName(name, NULL, &size, 0);
|
||||
ok(hr == E_NOT_SUFFICIENT_BUFFER || broken(hr == E_INVALIDARG), "got %08x\n", hr);
|
||||
ok(size == 5 || broken(size == 3), "got %u\n", size);
|
||||
|
||||
size = 3;
|
||||
str[0] = 'a';
|
||||
hr = IAssemblyName_GetDisplayName(name, str, &size, 0);
|
||||
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got %08x\n", hr);
|
||||
ok(str[0] == 'a', "got %c\n", str[0]);
|
||||
ok(size == 5, "got %u\n", size);
|
||||
|
||||
size = MAX_PATH;
|
||||
hr = IAssemblyName_GetDisplayName(name, str, &size, ASM_DISPLAYF_FULL);
|
||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||
|
|
Loading…
Reference in New Issue