fix: stack buffer overflow in PreviewWindow::drawTime (#1945)

This commit is contained in:
Raphael Coeffic
2022-05-07 21:34:29 +10:00
committed by GitHub
parent 7806d5f892
commit 26262c4c92
+6 -7
View File
@@ -282,15 +282,14 @@ class PreviewWindow : public FormGroup
{
// time on top bar
struct gtm t;
char str[10];
char str1[20];
char str[16];
const char *const STR_MONTHS[] = TR_MONTHS;
gettime(&t);
sprintf(str, "%d %s\n", t.tm_mday, STR_MONTHS[t.tm_mon]);
getTimerString(str1, getValue(MIXSRC_TX_TIME));
strcat(str, str1);
int s = snprintf(str, sizeof(str), "%d %s\n", t.tm_mday, STR_MONTHS[t.tm_mon]);
if (s > 0 && s < sizeof(str) - 6 /* 00:00\0 */) {
getTimerString(str + s, getValue(MIXSRC_TX_TIME));
}
dc->drawText(rect.w - 40, 5, str, COLOR_THEME_PRIMARY2 | FONT(XS));
}
@@ -334,4 +333,4 @@ class PreviewWindow : public FormGroup
tmr10ms_t ticks;
};
#endif
#endif