hid: Validate preparsed data pointer passed in HidP functions.

Power Rangers: Battle for the Grid.

0514:trace:hidp:HidP_GetCaps preparsed_data 000000004C9566B0, caps 000000000010EF00.
0514:trace:hidp:HidP_GetCaps preparsed_data 0000000000000000, caps 000000000010F020.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2021-08-10 11:31:13 +02:00 committed by Alexandre Julliard
parent 77930f1fe2
commit 656691feb7
1 changed files with 3 additions and 3 deletions

View File

@ -39,7 +39,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(hidp);
static NTSTATUS get_value_caps_range( WINE_HIDP_PREPARSED_DATA *preparsed, HIDP_REPORT_TYPE report_type, ULONG report_len,
const struct hid_value_caps **caps, const struct hid_value_caps **caps_end )
{
if (preparsed->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
if (!preparsed || preparsed->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
switch (report_type)
{
@ -167,7 +167,7 @@ NTSTATUS WINAPI HidP_GetCaps( PHIDP_PREPARSED_DATA preparsed_data, HIDP_CAPS *ca
TRACE( "preparsed_data %p, caps %p.\n", preparsed_data, caps );
if (preparsed->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
if (!preparsed || preparsed->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
*caps = preparsed->caps;
return HIDP_STATUS_SUCCESS;
@ -787,7 +787,7 @@ NTSTATUS WINAPI HidP_GetLinkCollectionNodes( HIDP_LINK_COLLECTION_NODE *nodes, U
TRACE( "nodes %p, nodes_len %p, preparsed_data %p.\n", nodes, nodes_len, preparsed_data );
if (preparsed->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
if (!preparsed || preparsed->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
count = *nodes_len = preparsed->caps.NumberLinkCollectionNodes;
if (capacity < count) return HIDP_STATUS_BUFFER_TOO_SMALL;