Commit 4ee3edf9 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput/tests: Enforce HID report descriptor buffer size.

parent b8a54fb1
......@@ -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;
......
......@@ -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;
......
......@@ -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 =
......
......@@ -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 =
......
......@@ -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 =
......
......@@ -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 =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment