From: Thomas Weißschuh Date: Tue, 26 Dec 2023 10:33:17 +0000 (+0100) Subject: pg: use snprintf to build string X-Git-Tag: v2.40-rc1~84^2~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b1324c5b0d97bf33e362a88c5e563e4adc4b6a2;p=thirdparty%2Futil-linux.git pg: use snprintf to build string Signed-off-by: Thomas Weißschuh --- diff --git a/text-utils/pg.c b/text-utils/pg.c index 262187289f..30ed04660b 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -618,9 +618,9 @@ static void prompt(long long pageno) if ((p = strstr(pstring, "%d")) == NULL) { mesg(pstring); } else { - strcpy(b, pstring); - sprintf(b + (p - pstring), "%lld", pageno); - strcat(b, p + 2); + snprintf(b, sizeof(b), + "%.*s%lld%s", (int) (p - pstring), pstring, + pageno, p + 2); mesg(b); } }