From 656691feb7d3ff979f255ac3c730ac357e4cbccd Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 10 Aug 2021 11:31:13 +0200 Subject: [PATCH] hid: Validate preparsed data pointer passed in HidP functions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/hid/hidp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 6259e0f56a9..37715ccfbca 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -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;