[PATCH 1/2] mmdevapi: Truncate strings from PropertyStore's GetValue to 62 chars.

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri May 20 12:40:18 CDT 2022


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53010
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

Not sure if this is the best solution, but...

 dlls/mmdevapi/devenum.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c
index ed1daa8..f5799be 100644
--- a/dlls/mmdevapi/devenum.c
+++ b/dlls/mmdevapi/devenum.c
@@ -1378,6 +1378,8 @@ 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 +1399,16 @@ 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;
+
+    /* Some broken apps and libs (e.g. Split/Second with fmodex)
+       can't deal with strings longer than 62 characters + NUL. */
+    if (pv->vt == VT_LPWSTR && wcslen(pv->pwszVal) > 62)
+        pv->pwszVal[62] = '\0';
+
+    return hres;
 }
 
 static HRESULT WINAPI MMDevPropStore_SetValue(IPropertyStore *iface, REFPROPERTYKEY key, REFPROPVARIANT pv)
-- 
2.34.1




More information about the wine-devel mailing list