Gabriel Ivăncescu : mmdevapi: Warn if returned device name is too long.
Module: wine Branch: master Commit: 653d04d7f9d30fcd608c6bbd6b83ce0febb66735 URL: https://source.winehq.org/git/wine.git/?a=commit;h=653d04d7f9d30fcd608c6bbd6... Author: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Date: Thu May 26 19:06:39 2022 +0300 mmdevapi: Warn if returned device name is too long. Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/mmdevapi/devenum.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c index 1354bf36a15..053275cac45 100644 --- a/dlls/mmdevapi/devenum.c +++ b/dlls/mmdevapi/devenum.c @@ -1378,6 +1378,7 @@ static HRESULT WINAPI MMDevPropStore_GetAt(IPropertyStore *iface, DWORD prop, PR static HRESULT WINAPI MMDevPropStore_GetValue(IPropertyStore *iface, REFPROPERTYKEY key, PROPVARIANT *pv) { MMDevPropStore *This = impl_from_IPropertyStore(iface); + HRESULT hres; TRACE("(%p)->(\"%s,%lu\", %p)\n", This, key ? debugstr_guid(&key->fmtid) : NULL, key ? key->pid : 0, pv); if (!key || !pv) @@ -1397,7 +1398,19 @@ static HRESULT WINAPI MMDevPropStore_GetValue(IPropertyStore *iface, REFPROPERTY return S_OK; } - return MMDevice_GetPropValue(&This->parent->devguid, This->parent->flow, key, pv); + hres = MMDevice_GetPropValue(&This->parent->devguid, This->parent->flow, key, pv); + if (FAILED(hres)) + return hres; + + if (WARN_ON(mmdevapi)) + { + if ((IsEqualPropertyKey(*key, DEVPKEY_Device_FriendlyName) || + IsEqualPropertyKey(*key, DEVPKEY_DeviceInterface_FriendlyName) || + IsEqualPropertyKey(*key, DEVPKEY_Device_DeviceDesc)) && + pv->vt == VT_LPWSTR && wcslen(pv->pwszVal) > 62) + WARN("Returned name exceeds length limit of some broken apps/libs, might crash: %s\n", debugstr_w(pv->pwszVal)); + } + return hres; } static HRESULT WINAPI MMDevPropStore_SetValue(IPropertyStore *iface, REFPROPERTYKEY key, REFPROPVARIANT pv)
participants (1)
-
Alexandre Julliard