From 8b1324c5b0d97bf33e362a88c5e563e4adc4b6a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 26 Dec 2023 11:33:17 +0100 Subject: [PATCH] pg: use snprintf to build string MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Weißschuh --- text-utils/pg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); } } -- 2.47.3