From 89609871560b5156dbdbd01ce6e09a706f6eda68 Mon Sep 17 00:00:00 2001 From: julen Date: Sun, 10 May 2026 12:59:33 +0800 Subject: [PATCH] fix: integer overflow when inactive_time exceeds 35 When the inactive_time configuration value exceeds 35, the expression `get_config().inactive_time * 60 * 1000 * 1000` overflows the maximum int value due to implicit integer conversion. --- src/bt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bt.cpp b/src/bt.cpp index e766dda..1a0f5f8 100644 --- a/src/bt.cpp +++ b/src/bt.cpp @@ -333,8 +333,8 @@ static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t } if (packet[3] < 120 || packet[3] > 140) { inactive_time = get_absolute_time(); - } else if (absolute_time_diff_us(inactive_time, get_absolute_time()) > get_config().inactive_time * 60 * - 1000 * 1000) { + } else if (absolute_time_diff_us(inactive_time, get_absolute_time()) > + static_cast(get_config().inactive_time) * 60 * 1000 * 1000) { printf("disconnect when inactive\n"); inactive_time = get_absolute_time(); bt_disconnect(); @@ -348,7 +348,7 @@ static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t #if !ENABLE_SERIAL tud_connect(); #endif - }else if (packet[0] == 0x02) { + } else if (packet[0] == 0x02) { printf("Connected DS5 Controller\n"); check_dse = false; is_dse = false;