[PATCH 3/4] dinput: Do not read/write past the struct for old DX versions

Bruno Jesus 00cpxxx at gmail.com
Mon Aug 22 20:06:57 CDT 2016


Based on ideas by Elias Vanderstuyft.

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
---
 dlls/dinput/effect_linuxinput.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index 2f3399d..642dfc0 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -329,9 +329,8 @@ static HRESULT WINAPI LinuxInputEffectImpl_GetParameters(
     	peff->dwSamplePeriod = 0;
     }
 
-    if (dwFlags & DIEP_STARTDELAY) {
-	peff->dwStartDelay = This->effect.replay.delay * 1000;
-    }
+    if ((dwFlags & DIEP_STARTDELAY) && peff->dwSize > sizeof(DIEFFECT_DX5))
+        peff->dwStartDelay = This->effect.replay.delay * 1000;
 
     if (dwFlags & DIEP_TRIGGERBUTTON) {
 	FIXME("LinuxInput button mapping needs redoing; for now, assuming we're using an actual joystick.\n");
@@ -570,7 +569,8 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
 	TRACE("Sample period requested but no sample period functionality present.\n");
 
     if (dwFlags & DIEP_STARTDELAY)
-	This->effect.replay.delay = peff->dwStartDelay / 1000;
+    if ((dwFlags & DIEP_STARTDELAY) && peff->dwSize > sizeof(DIEFFECT_DX5))
+        This->effect.replay.delay = peff->dwStartDelay / 1000;
 
     if (dwFlags & DIEP_TRIGGERBUTTON) {
 	if (peff->dwTriggerButton != -1) {
-- 
2.9.3




More information about the wine-patches mailing list