From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/driver_bus.c | 2 +- dlls/dinput/tests/driver_hid.h | 4 +++- dlls/dinput/tests/force_feedback.c | 11 +++++++---- dlls/dinput/tests/hid.c | 4 ++++ dlls/dinput/tests/hotplug.c | 1 + dlls/dinput/tests/joystick8.c | 21 ++++++++++++++++----- 6 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/dlls/dinput/tests/driver_bus.c b/dlls/dinput/tests/driver_bus.c index 45a984b6c36..9ece4414a1a 100644 --- a/dlls/dinput/tests/driver_bus.c +++ b/dlls/dinput/tests/driver_bus.c @@ -458,7 +458,7 @@ struct phys_device
BOOL use_report_id; DWORD report_descriptor_len; - char report_descriptor_buf[1024]; + char report_descriptor_buf[MAX_HID_DESCRIPTOR_LEN];
HIDP_CAPS caps; HID_DEVICE_ATTRIBUTES attributes; diff --git a/dlls/dinput/tests/driver_hid.h b/dlls/dinput/tests/driver_hid.h index 1010499fc41..4711d391bfe 100644 --- a/dlls/dinput/tests/driver_hid.h +++ b/dlls/dinput/tests/driver_hid.h @@ -62,13 +62,15 @@ struct hid_expect };
/* create/remove device */ +#define MAX_HID_DESCRIPTOR_LEN 2048 + struct hid_device_desc { BOOL is_polled; BOOL use_report_id;
DWORD report_descriptor_len; - char report_descriptor_buf[1024]; + char report_descriptor_buf[MAX_HID_DESCRIPTOR_LEN];
HIDP_CAPS caps; HID_DEVICE_ATTRIBUTES attributes; diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index 7128b89cea8..eae93fa72ad 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -1672,7 +1672,8 @@ static void test_condition_effect( IDirectInputDevice8W *device, HANDLE file, DW static BOOL test_force_feedback_joystick( DWORD version ) { #include "psh_hid_macros.h" - const unsigned char report_descriptor[] = { + const unsigned char report_descriptor[] = + { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), USAGE(1, HID_USAGE_GENERIC_JOYSTICK), COLLECTION(1, Application), @@ -2005,7 +2006,7 @@ static BOOL test_force_feedback_joystick( DWORD version ) END_COLLECTION, END_COLLECTION, }; -#undef REPORT_ID_OR_USAGE_PAGE + C_ASSERT(sizeof(report_descriptor) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = @@ -3460,6 +3461,7 @@ static void test_device_managed_effect(void) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(report_descriptor) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = @@ -4576,7 +4578,8 @@ struct bool_async_handler default_bool_async_handler = {{&bool_async_handler_vtb static void test_windows_gaming_input(void) { #include "psh_hid_macros.h" - const unsigned char report_desc[] = { + const unsigned char report_desc[] = + { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), USAGE(1, HID_USAGE_GENERIC_JOYSTICK), COLLECTION(1, Application), @@ -4997,7 +5000,7 @@ static void test_windows_gaming_input(void) END_COLLECTION, END_COLLECTION, }; -#undef REPORT_ID_OR_USAGE_PAGE + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c index aeafbd4dbc3..7e2d9cf86cf 100644 --- a/dlls/dinput/tests/hid.c +++ b/dlls/dinput/tests/hid.c @@ -2854,6 +2854,7 @@ static void test_hid_driver( DWORD report_id, DWORD polled ) END_COLLECTION, }; #undef REPORT_ID_OR_USAGE_PAGE + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
const HIDP_CAPS caps = @@ -3062,6 +3063,7 @@ static void test_hidp_kdr(void) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = @@ -3571,6 +3573,7 @@ DWORD WINAPI dinput_test_device_thread( void *stop_event ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(gamepad_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h" static const HID_DEVICE_ATTRIBUTES attributes = { @@ -3615,6 +3618,7 @@ static void test_bus_driver(void) INPUT(1, Data|Var|Abs), END_COLLECTION, }; + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
static const HID_DEVICE_ATTRIBUTES attributes = diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c index e68a6914684..3f4aae3afac 100644 --- a/dlls/dinput/tests/hotplug.c +++ b/dlls/dinput/tests/hotplug.c @@ -133,6 +133,7 @@ static BOOL test_input_lost( DWORD version ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index 890209cd5e0..60a73769549 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -396,7 +396,7 @@ static void test_simple_joystick( DWORD version ) END_COLLECTION, END_COLLECTION, }; -#undef REPORT_ID_OR_USAGE_PAGE + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = @@ -2110,6 +2110,7 @@ static BOOL test_device_types( DWORD version ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(unknown_desc) < MAX_HID_DESCRIPTOR_LEN); static const unsigned char limited_desc[] = { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), @@ -2140,6 +2141,7 @@ static BOOL test_device_types( DWORD version ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(limited_desc) < MAX_HID_DESCRIPTOR_LEN); static const unsigned char gamepad_desc[] = { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), @@ -2170,6 +2172,7 @@ static BOOL test_device_types( DWORD version ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(gamepad_desc) < MAX_HID_DESCRIPTOR_LEN); static const unsigned char joystick_desc[] = { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), @@ -2210,6 +2213,7 @@ static BOOL test_device_types( DWORD version ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(joystick_desc) < MAX_HID_DESCRIPTOR_LEN); static const unsigned char wheel_steering_only_desc[] = { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), @@ -2248,6 +2252,7 @@ static BOOL test_device_types( DWORD version ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(wheel_steering_only_desc) < MAX_HID_DESCRIPTOR_LEN); static const unsigned char wheel_dualpedals_desc[] = { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), @@ -2289,6 +2294,7 @@ static BOOL test_device_types( DWORD version ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(wheel_dualpedals_desc) < MAX_HID_DESCRIPTOR_LEN); static const unsigned char wheel_threepedals_desc[] = { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), @@ -2331,6 +2337,7 @@ static BOOL test_device_types( DWORD version ) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(wheel_threepedals_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
static struct device_desc device_desc[] = @@ -2690,7 +2697,7 @@ static void test_many_axes_joystick(void) END_COLLECTION, END_COLLECTION, }; -#undef REPORT_ID_OR_USAGE_PAGE + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = @@ -3221,7 +3228,7 @@ static void test_driving_wheel_axes(void) END_COLLECTION, END_COLLECTION, }; -#undef REPORT_ID_OR_USAGE_PAGE + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = @@ -3415,7 +3422,8 @@ done: static BOOL test_winmm_joystick(void) { #include "psh_hid_macros.h" - const unsigned char report_desc[] = { + const unsigned char report_desc[] = + { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), USAGE(1, HID_USAGE_GENERIC_JOYSTICK), COLLECTION(1, Application), @@ -3461,6 +3469,7 @@ static BOOL test_winmm_joystick(void) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc = @@ -3864,7 +3873,8 @@ static struct controller_handler controller_added = {{&controller_handler_vtbl}} static void test_windows_gaming_input(void) { #include "psh_hid_macros.h" - const unsigned char report_desc[] = { + const unsigned char report_desc[] = + { USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), USAGE(1, HID_USAGE_GENERIC_GAMEPAD), COLLECTION(1, Application), @@ -3906,6 +3916,7 @@ static void test_windows_gaming_input(void) END_COLLECTION, END_COLLECTION, }; + C_ASSERT(sizeof(report_desc) < MAX_HID_DESCRIPTOR_LEN); #include "pop_hid_macros.h"
struct hid_device_desc desc =