Commit 2eda884b authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

fusion: Fix insufficient buffer size handling in IAssemblyName::GetDisplayName.

parent 382b72d7
......@@ -228,12 +228,10 @@ static HRESULT WINAPI IAssemblyNameImpl_GetDisplayName(IAssemblyName *iface,
LPDWORD pccDisplayName,
DWORD dwDisplayFlags)
{
static const WCHAR equals[] = {'=',0};
IAssemblyNameImpl *name = impl_from_IAssemblyName(iface);
WCHAR verstr[30];
WCHAR verstr[30], *cultureval = NULL;
DWORD size;
LPWSTR cultureval = 0;
static const WCHAR equals[] = {'=',0};
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;
if (*pccDisplayName < size)
{
*pccDisplayName = size;
return E_NOT_SUFFICIENT_BUFFER;
}
lstrcpynW(szDisplayName, name->displayname, size);
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment