Skip to content

Commit

Permalink
Merge branch 'bugfix/usleep_overflow_v5.3' into 'release/v5.3'
Browse files Browse the repository at this point in the history
fix(newlib): fixed potential overflow in usleep (v5.3)

See merge request espressif/esp-idf!33001
  • Loading branch information
ESP-Marius committed Sep 4, 2024
2 parents 14f7232 + d777b8e commit 07f531e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/newlib/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ WEAK_UNLESS_TIMEFUNC_IMPL int settimeofday(const struct timeval *tv, const struc

int usleep(useconds_t us)
{
const int us_per_tick = portTICK_PERIOD_MS * 1000;
/* Even at max tick rate, vTaskDelay can still delay for the max of the us argument,
we just need to make sure the tick calculation does not overflow
*/
const int64_t us_per_tick = portTICK_PERIOD_MS * 1000;
if (us < us_per_tick) {
esp_rom_delay_us((uint32_t) us);
} else {
Expand Down

0 comments on commit 07f531e

Please sign in to comment.