From 2d7c71133a37c1308d6560087fbad6f3306c7b47 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Fri, 6 Sep 2019 17:21:27 +0200 Subject: executor/usb: allow syz_usb_control_io args to be 0 --- executor/common_usb.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'executor') diff --git a/executor/common_usb.h b/executor/common_usb.h index 1442bef47..bf8d9b6d7 100644 --- a/executor/common_usb.h +++ b/executor/common_usb.h @@ -418,8 +418,13 @@ struct vusb_responses { static bool lookup_control_response(struct vusb_descriptors* descs, struct vusb_responses* resps, struct usb_ctrlrequest* ctrl, char** response_data, uint32* response_length) { - int descs_num = (descs->len - offsetof(struct vusb_descriptors, descs)) / sizeof(descs->descs[0]); - int resps_num = (resps->len - offsetof(struct vusb_responses, resps)) / sizeof(resps->resps[0]); + int descs_num = 0; + int resps_num = 0; + + if (descs) + descs_num = (descs->len - offsetof(struct vusb_descriptors, descs)) / sizeof(descs->descs[0]); + if (resps) + resps_num = (resps->len - offsetof(struct vusb_responses, resps)) / sizeof(resps->resps[0]); uint8 req = ctrl->bRequest; uint8 req_type = ctrl->bRequestType & USB_TYPE_MASK; -- cgit mrf-deployment