[PATCH 0/2] MR10072: shell32: Always update `outlen` (`pcchOut`) when querying strings
At least `AssocQueryStringW()` is documented to update the character count in `pcchOut` to "the number of characters actually placed in the buffer" which requires us to update the value of `*outlen` even when the buffer size was sufficient: https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-assoc... Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59402 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10072
From: Marijn Suijten <marijns95@gmail.com> At least `AssocQueryStringW()` is documented to update the character count in `pcchOut` to "the number of characters actually placed in the buffer" which requires us to update the value of `*outlen` even when the buffer size was sufficient: https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-assoc... Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59402 --- dlls/shell32/assoc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/shell32/assoc.c b/dlls/shell32/assoc.c index 74df71241e4..fb96311eeef 100644 --- a/dlls/shell32/assoc.c +++ b/dlls/shell32/assoc.c @@ -464,7 +464,10 @@ static HRESULT ASSOC_ReturnString(ASSOCF flags, LPWSTR out, DWORD *outlen, LPCWS *outlen = datalen; } else + { len = datalen; + *outlen = datalen; + } if (len) memcpy(out, data, len*sizeof(WCHAR)); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10072
From: Marijn Suijten <marijns95@gmail.com> According to https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-assoc... `pcchOut` should retain "the number of characters actually placed in the buffer" which will be the maximum length of the buffer if `datalen` (the actual length of the data to be returned) exceeds it. It seems that behaviour shouldn't change unless `ASSOCF_NOTRUNCATE` is set (or `out` is NULL) which doesn't return any data but only the actual required length of the buffer. Hence only update the `*pcchOut` argument (represented by `*outlen` here) if the flag was set. Also remove the unneeded `min()` as we already know that `*outlen` is smaller than `datalen`. --- dlls/shell32/assoc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/shell32/assoc.c b/dlls/shell32/assoc.c index fb96311eeef..a9ee3dd6f4e 100644 --- a/dlls/shell32/assoc.c +++ b/dlls/shell32/assoc.c @@ -455,13 +455,13 @@ static HRESULT ASSOC_ReturnString(ASSOCF flags, LPWSTR out, DWORD *outlen, LPCWS len = 0; if (*outlen > 0) out[0] = 0; hr = E_POINTER; + *outlen = datalen; } else { - len = min(*outlen, datalen); + len = *outlen; hr = E_NOT_SUFFICIENT_BUFFER; } - *outlen = datalen; } else { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10072
participants (2)
-
Marijn Suijten -
Marijn Suijten (@Marijn)