Fix buffer overflow when displaying measurements

This commit is contained in:
Andreas Eversberg
2024-03-10 11:43:00 +01:00
parent bc3967ccb6
commit e7efcee289

View File

@@ -247,7 +247,7 @@ static void print_measurements(int on)
memset(line_color + width - MAX_UNIT_LEN, 4, MAX_UNIT_LEN); /* blue */ memset(line_color + width - MAX_UNIT_LEN, 4, MAX_UNIT_LEN); /* blue */
else else
memset(line_color + width - MAX_UNIT_LEN, 3, MAX_UNIT_LEN); /* yellow */ memset(line_color + width - MAX_UNIT_LEN, 3, MAX_UNIT_LEN); /* yellow */
memcpy(line + width - MAX_UNIT_LEN + 1, text, MAX(strlen(text), MAX_UNIT_LEN)); memcpy(line + width - MAX_UNIT_LEN + 1, text, MIN(strlen(text), MAX_UNIT_LEN - 1));
display_line(on, width); display_line(on, width);
} }
} }