[PATCH 1/2] fusion: Fix IAssemblyNameImpl_GetDisplayName behavior on too small buffer
Piotr Caban <[email protected]> Fri, 10 Nov 2017 12:25:10 +0100
| Newsgroups | gmane.comp.emulators.wine.patches |
|---|---|
| Message-ID | <[email protected]> |
Signed-off-by: Piotr Caban <[email protected]> --- dlls/fusion/asmname.c | 5 ++++- dlls/fusion/tests/asmname.c | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
0001-fusion-Fix-IAssemblyNameImpl_GetDisplayName-behavior-o.txt
(text/x-patch, 1.3 KB)
diff --git a/dlls/fusion/asmname.c b/dlls/fusion/asmname.c
index 6be8bf6a87..96345b6db0 100644
--- a/dlls/fusion/asmname.c
+++ b/dlls/fusion/asmname.c
@@ -332,7 +332,10 @@ static HRESULT WINAPI IAssemblyNameImpl_GetDisplayName(IAssemblyName *iface,
size += lstrlenW(separator) + lstrlenW(procarch) + lstrlenW(equals) + lstrlenW(name->procarch);
if (size > *pccDisplayName)
- return S_FALSE;
+ {
+ *pccDisplayName = size;
+ return E_NOT_SUFFICIENT_BUFFER;
+ }
/* Construct the string */
lstrcpyW(szDisplayName, name->name);
diff --git a/dlls/fusion/tests/asmname.c b/dlls/fusion/tests/asmname.c
index aa7e11bf42..e1ef1d8190 100644
--- a/dlls/fusion/tests/asmname.c
+++ b/dlls/fusion/tests/asmname.c
@@ -537,6 +537,13 @@ static void test_CreateAssemblyNameObject(void)
ok(str[0] == 'a', "got %c\n", str[0]);
ok(size == 5, "got %u\n", size);
+ size = 0;
+ str[0] = 'a';
+ hr = IAssemblyName_GetDisplayName(name, str, &size, ASM_DISPLAYF_FULL);
+ ok(hr == E_NOT_SUFFICIENT_BUFFER, "got %08x\n", hr);
+ ok(str[0] == 'a', "got %c\n", str[0]);
+ ok(size == 5, "Wrong size %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);