From efb18899d23d8bbfa56f871c0d1fd44ac6bb838e Mon Sep 17 00:00:00 2001 From: anteater <65555601+nt8r@users.noreply.github.com> Date: Mon, 29 May 2023 20:59:11 +0000 Subject: [PATCH] dmesg: make kmsg read() buffer big enough for kernel otherwise, if the kernel log has an item longer than 1024B, our read() gives EINVAL and we stop reading kmsg --- sys-utils/dmesg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 45075e50bd..717cc588b2 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -179,7 +179,13 @@ struct dmesg_control { int kmsg; /* /dev/kmsg file descriptor */ ssize_t kmsg_first_read;/* initial read() return code */ - char kmsg_buf[BUFSIZ];/* buffer to read kmsg data */ + /* + * the kernel will give EINVAL if we do read() on /proc/kmsg with + * length insufficient for the next message. messages may be up to + * PRINTK_MESSAGE_MAX, which is defined as 2048, so we must be + * able to buffer at least that much in one call + */ + char kmsg_buf[2048]; /* buffer to read kmsg data */ usec_t since; /* filter records by time */ usec_t until; /* filter records by time */ -- 2.47.3