Skip to content

Commit 81cec6a

Browse files
authored
Update usermod_seven_segment_reloaded.h - prevent array bounds violation (solves wled#4121)
I'm not the maintainer of this usermod, but its obvious that the code might overrun array bounds, so fixing this.
1 parent 0642b17 commit 81cec6a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ class UsermodSSDR : public Usermod {
236236
}
237237

238238
void _setLeds(int lednr, int lastSeenLedNr, bool range, int countSegments, int number, bool colon) {
239+
if ((lednr < 0) || (lednr >= umSSDRLength)) return; // prevent array bounds violation
240+
if ((number < 0) || (countSegments < 0) || (lastSeenLedNr <0)) return; // prevent array out of range access
239241

240242
if ((colon && umSSDRColonblink) || umSSDRNumbers[number][countSegments]) {
241243

0 commit comments

Comments
 (0)