[PATCH 0/2] MR1493: dinput: Prevent a potential array overflow error + remove redundant physical range values.
From: Ivo Ivanov <logos128(a)gmail.com> Signed-off-by: Ivo Ivanov <logos128(a)gmail.com> --- dlls/dinput/joystick_hid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index ebebbee6eb2..3ea15009d8f 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2350,7 +2350,8 @@ static void convert_directions_from_spherical( const DIEFFECT *in, DIEFFECT *out tmp = cos( in->rglDirection[i - 1] * M_PI / 18000 ) * 10000; for (j = 0; j < i; ++j) out->rglDirection[j] = round( out->rglDirection[j] * tmp / 10000.0 ); - out->rglDirection[i] = sin( in->rglDirection[i - 1] * M_PI / 18000 ) * 10000; + if (i < in->cAxes) + out->rglDirection[i] = sin( in->rglDirection[i - 1] * M_PI / 18000 ) * 10000; } out->cAxes = in->cAxes; break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1493
From: Ivo Ivanov <logos128(a)gmail.com> The physical range is not correct for the given usage. Signed-off-by: Ivo Ivanov <logos128(a)gmail.com> --- dlls/dinput/joystick_hid.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 3ea15009d8f..2065fe429eb 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1845,8 +1845,6 @@ static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *cap if (instance->wCollectionNumber == effect_update->axes_coll) { SET_REPORT_ID( effect_update ); - caps->physical_min = 0; - caps->physical_max = 36000; if (effect_update->axis_count >= 6) FIXME( "more than 6 PID axes detected\n" ); else effect_update->axis_caps[effect_update->axis_count] = caps; effect_update->axis_count++; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1493
Rémi Bernon (@rbernon) commented about dlls/dinput/joystick_hid.c:
{ case DIEFF_CARTESIAN: out->rglDirection[0] = 10000; for (i = 1; i <= in->cAxes; ++i)
Shouldn't this instead be `<`? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1493#note_16930
FWIW since we've moved to Gitlab and MR approvals you don't have to add commit sign-offs anymore. And you'd only need to approve your own MR if you're including commits from a third person. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1493#note_16931
On Tue Nov 22 12:14:29 2022 +0000, Rémi Bernon wrote:
Shouldn't this instead be `<`? This way it won't cover the last element in rglDirection later in the loop.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/1493#note_16943
On Tue Nov 22 13:11:45 2022 +0000, Ivo Ivanov wrote:
This way it won't cover the last element in rglDirection later in the loop. Oh yes ofc, sorry.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/1493#note_16944
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1493
participants (3)
-
Ivo Ivanov -
Ivo Ivanov (@logos128) -
Rémi Bernon