Skip to content

Commit

Permalink
Fix buffer overflow when trying to display long GitVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
nica-f committed Jan 11, 2019
1 parent 3761c3c commit 2eed223
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ int main(void) {
printf("\nRunning on an %s", buf);

len = snprintf(buf, sizeof(buf), "%s", Version_GetGitVersion());
if (len > 21)
len = 21;
LCD_disp_str((uint8_t*)buf, len, 128 - (len * 6), 0, FONT6X6);

LCD_FB_Update();
Expand Down Expand Up @@ -349,6 +351,8 @@ static int32_t Main_Work(void) {
LCD_disp_str((uint8_t*)buf, len, LCD_ALIGN_CENTER(len), 0, FONT6X6);

len = snprintf(buf, sizeof(buf), "%s", Version_GetGitVersion());
if (len > 21)
len = 21;
LCD_disp_str((uint8_t*)buf, len, LCD_ALIGN_CENTER(len), 64 - 6, FONT6X6);

LCD_BMPDisplay(stopbmp, 127 - 17, 0);
Expand Down

0 comments on commit 2eed223

Please sign in to comment.