From: Karel Zak Date: Tue, 18 Feb 2025 09:58:00 +0000 (+0100) Subject: pg: make sure cmdline[] not overflow [coverity scan] X-Git-Tag: v2.42-start~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54eb6321dd7b7797b1831192af2058e8838f0d19;p=thirdparty%2Futil-linux.git pg: make sure cmdline[] not overflow [coverity scan] Signed-off-by: Karel Zak --- diff --git a/text-utils/pg.c b/text-utils/pg.c index 6d67bc579..3623f3f78 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -748,6 +748,10 @@ static void prompt(long long pageno) } } write_all(STDOUT_FILENO, &key, 1); + + if (cmd.cmdlen + 1 >= sizeof(cmd.cmdline)) + goto endprompt; + cmd.cmdline[cmd.cmdlen++] = key; cmd.cmdline[cmd.cmdlen] = '\0'; if (nflag && state == CMD_FIN)