]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
pg: use snprintf to build string
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 26 Dec 2023 10:33:17 +0000 (11:33 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 31 Dec 2023 12:04:23 +0000 (13:04 +0100)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
text-utils/pg.c

index 262187289fe7a51caf93fba97e758cf1f319e2e4..30ed04660ba5dc6948a83f29c86b95b37b9be625 100644 (file)
@@ -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);
                }
        }