fix: stack buffer overflow in PreviewWindow::drawTime (#1945)
This commit is contained in:
@@ -282,15 +282,14 @@ class PreviewWindow : public FormGroup
|
|||||||
{
|
{
|
||||||
// time on top bar
|
// time on top bar
|
||||||
struct gtm t;
|
struct gtm t;
|
||||||
char str[10];
|
char str[16];
|
||||||
char str1[20];
|
|
||||||
const char *const STR_MONTHS[] = TR_MONTHS;
|
const char *const STR_MONTHS[] = TR_MONTHS;
|
||||||
|
|
||||||
gettime(&t);
|
gettime(&t);
|
||||||
sprintf(str, "%d %s\n", t.tm_mday, STR_MONTHS[t.tm_mon]);
|
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(str1, getValue(MIXSRC_TX_TIME));
|
getTimerString(str + s, getValue(MIXSRC_TX_TIME));
|
||||||
strcat(str, str1);
|
}
|
||||||
dc->drawText(rect.w - 40, 5, str, COLOR_THEME_PRIMARY2 | FONT(XS));
|
dc->drawText(rect.w - 40, 5, str, COLOR_THEME_PRIMARY2 | FONT(XS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user