---
 toys/lsb/dmesg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
From aef656c27db69173a6876a8d2d8378ac649b137a Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Mon, 7 Jun 2021 17:41:22 -0700
Subject: [PATCH] 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;
-- 
2.32.0.rc1.229.g3e70b5a671-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to