From f6f6e8593a81f5fdcec4e361c28e861bee23fe62 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 24 Jan 2018 00:36:32 +0100 Subject: [PATCH] bootloader: don't crash on empty usb queue --- embed/bootloader/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/embed/bootloader/main.c b/embed/bootloader/main.c index 00d18042d..f7f70e38a 100644 --- a/embed/bootloader/main.c +++ b/embed/bootloader/main.c @@ -210,7 +210,9 @@ static secbool bootloader_loop(secbool firmware_present) #else int r = usb_hid_read_blocking(USB_IFACE_NUM, buf, USB_PACKET_SIZE, USB_TIMEOUT); #endif - ensure(sectrue * (r == USB_PACKET_SIZE), NULL); + if (r != USB_PACKET_SIZE) { + continue; + } uint16_t msg_id; uint32_t msg_size; if (sectrue != msg_parse_header(buf, &msg_id, &msg_size)) {