dinput: Check sizes in HID joystick IDirectInputDevice8_GetProperty.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0daf841712
commit
b4dfa8ff7b
|
@ -500,28 +500,33 @@ static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, con
|
|||
TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
|
||||
|
||||
if (!header) return DIERR_INVALIDPARAM;
|
||||
if (header->dwHeaderSize != sizeof(DIPROPHEADER)) return DIERR_INVALIDPARAM;
|
||||
if (!IS_DIPROP( guid )) return DI_OK;
|
||||
|
||||
switch (LOWORD( guid ))
|
||||
{
|
||||
case (DWORD_PTR)DIPROP_RANGE:
|
||||
if (header->dwSize != sizeof(DIPROPRANGE)) return DIERR_INVALIDPARAM;
|
||||
enum_value_objects( impl, header, DIDFT_AXIS, get_property_prop_range, header );
|
||||
return DI_OK;
|
||||
case (DWORD_PTR)DIPROP_PRODUCTNAME:
|
||||
{
|
||||
DIPROPSTRING *value = (DIPROPSTRING *)header;
|
||||
if (header->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
|
||||
lstrcpynW( value->wsz, impl->instance.tszProductName, MAX_PATH );
|
||||
return DI_OK;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_INSTANCENAME:
|
||||
{
|
||||
DIPROPSTRING *value = (DIPROPSTRING *)header;
|
||||
if (header->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
|
||||
lstrcpynW( value->wsz, impl->instance.tszInstanceName, MAX_PATH );
|
||||
return DI_OK;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_VIDPID:
|
||||
{
|
||||
DIPROPDWORD *value = (DIPROPDWORD *)header;
|
||||
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
||||
if (!impl->attrs.VendorID || !impl->attrs.ProductID) return DIERR_UNSUPPORTED;
|
||||
value->dwData = MAKELONG( impl->attrs.VendorID, impl->attrs.ProductID );
|
||||
return DI_OK;
|
||||
|
@ -529,12 +534,14 @@ static HRESULT WINAPI hid_joystick_GetProperty( IDirectInputDevice8W *iface, con
|
|||
case (DWORD_PTR)DIPROP_JOYSTICKID:
|
||||
{
|
||||
DIPROPDWORD *value = (DIPROPDWORD *)header;
|
||||
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
||||
value->dwData = impl->instance.guidInstance.Data3;
|
||||
return DI_OK;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_GUIDANDPATH:
|
||||
{
|
||||
DIPROPGUIDANDPATH *value = (DIPROPGUIDANDPATH *)header;
|
||||
if (header->dwSize != sizeof(DIPROPGUIDANDPATH)) return DIERR_INVALIDPARAM;
|
||||
lstrcpynW( value->wszPath, impl->device_path, MAX_PATH );
|
||||
return DI_OK;
|
||||
}
|
||||
|
@ -566,11 +573,13 @@ static HRESULT WINAPI hid_joystick_SetProperty( IDirectInputDevice8W *iface, con
|
|||
TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
|
||||
|
||||
if (!header) return DIERR_INVALIDPARAM;
|
||||
if (header->dwHeaderSize != sizeof(DIPROPHEADER)) return DIERR_INVALIDPARAM;
|
||||
if (!IS_DIPROP( guid )) return DI_OK;
|
||||
|
||||
switch (LOWORD( guid ))
|
||||
{
|
||||
case (DWORD_PTR)DIPROP_RANGE:
|
||||
if (header->dwSize != sizeof(DIPROPRANGE)) return DIERR_INVALIDPARAM;
|
||||
enum_value_objects( impl, header, DIDFT_AXIS, set_property_prop_range, (void *)header );
|
||||
return DI_OK;
|
||||
default:
|
||||
|
|
|
@ -3785,11 +3785,9 @@ static void test_simple_joystick(void)
|
|||
hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, NULL );
|
||||
ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetProperty returned %#x\n", hr );
|
||||
hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, &prop_string.diph );
|
||||
todo_wine
|
||||
ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetProperty returned %#x\n", hr );
|
||||
prop_dword.diph.dwHeaderSize = sizeof(DIPROPHEADER) - 1;
|
||||
hr = IDirectInputDevice8_GetProperty( device, DIPROP_VIDPID, &prop_dword.diph );
|
||||
todo_wine
|
||||
ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_GetProperty returned %#x\n", hr );
|
||||
prop_dword.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
|
||||
|
|
Loading…
Reference in New Issue