Skip to content

Commit

Permalink
Fix buffer overflow in LCD_disp_str
Browse files Browse the repository at this point in the history
This buffer overflow occur when right tc offet is >= 10.00 or <=-10.00
in this case, there is 22 chars to be displayed on the line.
This also occur with long version string as v0.5.2-4-dirty-gxxxxxx.
This cause reboot of the firmware.

note from snprintf(3) :
snprintf return the return value is the number of characters (excluding the terminating null byte) which would have  been
written  to the final string if enough space had been available.
  • Loading branch information
mcapdeville committed Oct 24, 2023
1 parent 217281c commit 83efa20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ void charoutsmall(uint8_t theChar, uint8_t X, uint8_t Y) {

void LCD_disp_str(uint8_t* theStr, uint8_t theLen, uint8_t startx, uint8_t y, uint8_t theFormat) {
#ifdef MINIMALISTIC
for (uint8_t q = 0; q < theLen; q++) {
for (uint8_t q = 0; q < theLen && startx<=(FB_WIDTH-6); q++) {
charoutsmall(theStr[q], startx, y);
startx += 6;
}
#else
uint8_t invmask = theFormat & 0x80;
for(uint8_t q = 0; q < theLen; q++) {
for(uint8_t q = 0; q < theLen && startx<=(FB_WIDTH-6); q++) {
charoutsmall(theStr[q] | invmask, startx, y);
startx += 6;
}
Expand Down

0 comments on commit 83efa20

Please sign in to comment.