Skip to content

Commit

Permalink
NUM_MODULES bounds check
Browse files Browse the repository at this point in the history
Add a check to showString() to prevent buffer overrun.
  • Loading branch information
kitlaan authored Oct 24, 2023
1 parent ef8d7dc commit aaa8917
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arduino/splitflap/esp32/core/splitflap_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void SplitflapTask::log(const char* msg) {
void SplitflapTask::showString(const char* str, uint8_t length, bool force_full_rotation) {
Command command = {};
command.command_type = CommandType::MODULES;
for (uint8_t i = 0; i < length; i++) {
for (uint8_t i = 0; i < length && i < NUM_MODULES; i++) {
int8_t index = findFlapIndex(str[i]);
if (index != -1) {
if (force_full_rotation || index != modules[i]->GetTargetFlapIndex()) {
Expand Down

0 comments on commit aaa8917

Please sign in to comment.