From e7efcee289bf2df88c57d487f29be4ec23a45594 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 10 Mar 2024 11:43:00 +0100 Subject: [PATCH] Fix buffer overflow when displaying measurements --- src/libdisplay/display_measurements.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libdisplay/display_measurements.c b/src/libdisplay/display_measurements.c index 84a88bc..e4fc040 100644 --- a/src/libdisplay/display_measurements.c +++ b/src/libdisplay/display_measurements.c @@ -247,7 +247,7 @@ static void print_measurements(int on) memset(line_color + width - MAX_UNIT_LEN, 4, MAX_UNIT_LEN); /* blue */ else 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); } }