]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
pg: make sure cmdline[] not overflow [coverity scan]
authorKarel Zak <kzak@redhat.com>
Tue, 18 Feb 2025 09:58:00 +0000 (10:58 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 18 Feb 2025 09:58:00 +0000 (10:58 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/pg.c

index 6d67bc579c5f9986c62147360cf72958ab0fbafc..3623f3f787f8bc9411321f9ed1ed036c3ee3a628 100644 (file)
@@ -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)