From 925f2e914ba125af43b14fadec60e55cd2f8c7a1 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 10 Feb 2021 09:49:42 +0000 Subject: [PATCH] logitech-hidpp: Read from the device in a more safe way --- plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c index 334f0695a..04ac1c178 100644 --- a/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c @@ -861,7 +861,9 @@ fu_logitech_hidpp_peripheral_write_firmware_pkt (FuLogitechHidPpPeripheral *self } /* check error */ - packet_cnt = fu_common_read_uint32 (msg->data, G_BIG_ENDIAN); + if (!fu_common_read_uint32_safe (msg->data, sizeof(msg->data), 0x0, + &packet_cnt, G_BIG_ENDIAN, error)) + return FALSE; g_debug ("packet_cnt=0x%04x", packet_cnt); if (fu_logitech_hidpp_peripheral_check_status (msg->data[4], &error_local)) return TRUE;