From a98967539299b6dae1fc786278299efabebfa928 Mon Sep 17 00:00:00 2001 From: ShubhamDesai <42180509+ShubhamDesai@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:38:27 -0500 Subject: [PATCH] lib/display: Fix Copy Buffer Size issue in tran_colr.c (#4851) --- lib/display/tran_colr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/display/tran_colr.c b/lib/display/tran_colr.c index 63975f18799..2c416abaecc 100644 --- a/lib/display/tran_colr.c +++ b/lib/display/tran_colr.c @@ -4,10 +4,12 @@ #include -#include #include -#include +#include +#include #include +#include + #include "driver.h" static struct color_rgb *colors; @@ -38,7 +40,9 @@ static int translate_or_add_color(const char *str) char lowerstr[MAX_COLOR_LEN]; /* Make the color string lowercase for display colors */ - strcpy(lowerstr, str); + if (G_strlcpy(lowerstr, str, sizeof(lowerstr)) >= sizeof(lowerstr)) { + G_fatal_error(_("String <%s> is too long"), str); + } G_chop(lowerstr); G_tolcase(lowerstr);