]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
logger: fix buffer overflow when read stdin
authorKarel Zak <kzak@redhat.com>
Wed, 10 Sep 2025 08:31:23 +0000 (10:31 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 10 Sep 2025 08:31:23 +0000 (10:31 +0200)
$ perl -e 'print "<" . "0"x10240' | logger --prio-prefix
Segmentation fault (core dumped)

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/logger.c

index a674ef0cf9489fb058549c35d006786c091cfbfa..d27c8064f321847b24c59b294587edee8c82c047 100644 (file)
@@ -1025,7 +1025,9 @@ static void logger_stdin(struct logger_ctl *ctl)
                if (ctl->prio_prefix && c == '<') {
                        pri = 0;
                        buf[i++] = c;
-                       while (isdigit(c = getchar()) && pri <= 191) {
+                       while (i < ctl->max_message_size
+                              && isdigit(c = getchar()) && pri <= 191) {
+
                                buf[i++] = c;
                                pri = pri * 10 + c - '0';
                        }