From 5f27480f26cb3c3329fdf4f1d7047ee11c6d1a95 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 23 May 2024 19:01:30 -0400 Subject: kernel: intr: Fix garbage output Signed-off-by: Ian Moffett --- sys/kern/kern_intr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sys') diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index e37c87e..0c80334 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -65,9 +65,15 @@ proc_read(struct proc_entry *entry, struct sio_txn *sio) idx += res; p += res; } + + if (idx >= (PROC_BUF_SIZE - 1)) { + break; + } } - len = strlen(buf); + len = idx + 1; + buf[idx] = '\0'; + if (sio->len > PROC_BUF_SIZE) sio->len = PROC_BUF_SIZE; if (len > sio->len) @@ -75,7 +81,7 @@ proc_read(struct proc_entry *entry, struct sio_txn *sio) memcpy(sio->buf, buf, len); mutex_release(&intrlist_lock); - return sio->len; + return len; } /* -- cgit v1.2.3