From 7ee66e9aec520afa1138876074b815295b6d1821 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 7 Jun 2021 17:41:22 -0700 Subject: dmesg.c: fix off-by-one. --- toys/lsb/dmesg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toys/lsb/dmesg.c b/toys/lsb/dmesg.c index 829fcd54..8736a8e5 100644 --- a/toys/lsb/dmesg.c +++ b/toys/lsb/dmesg.c @@ -141,7 +141,7 @@ void dmesg_main(void) for (;;) { // why does /dev/kmesg return EPIPE instead of EAGAIN if oldest message // expires as we read it? - if (-1==(len = read(fd, msg, sizeof(msg))) && errno==EPIPE) continue; + if (-1==(len = read(fd, msg, sizeof(msg)-1)) && errno==EPIPE) continue; // read() from kmsg always fails on a pre-3.5 kernel. if (len==-1 && errno==EINVAL) goto klogctl_mode; if (len<1) break; -- cgit v1.2.3