From 1d0c3c0c1c94495807255ac419219fb51bbce674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Mon, 9 Jan 2023 10:15:59 +0100 Subject: [PATCH] FIX: Buffer overflow: Mode::timers --- src/mode/Mode.h | 2 +- src/serial.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mode/Mode.h b/src/mode/Mode.h index d5586b3..dffb6f1 100644 --- a/src/mode/Mode.h +++ b/src/mode/Mode.h @@ -127,7 +127,7 @@ private: void handleTimers() { milliseconds_t ms = millis(); - for (Timer *timer = timers; timer < timers + sizeof(timers); timer++) { + for (Timer *timer = timers; timer < timers + countof(timers); timer++) { if (timer->interval > 0) { milliseconds_t milliseconds = ms - timer->last; if (milliseconds >= timer->interval) { diff --git a/src/serial.cpp b/src/serial.cpp index a0ebcc6..6dd0116 100644 --- a/src/serial.cpp +++ b/src/serial.cpp @@ -23,7 +23,10 @@ void serial_loop() { case '7': case '8': case '9': - setMode((ModeId)(input - '0')); + setMode((ModeId) (input - '0')); + break; + case 'a': + setMode((ModeId) (input - 'a')); break; case '+': setBrightness(display.getBrightness() + 10);