Module Name:    src
Committed By:   mlelstv
Date:           Sat May  4 13:33:18 UTC 2024

Modified Files:
        src/sys/kern: subr_iostat.c

Log Message:
Account for trailing NUL bytes when calculating userland buffer size.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/kern/subr_iostat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_iostat.c
diff -u src/sys/kern/subr_iostat.c:1.25 src/sys/kern/subr_iostat.c:1.26
--- src/sys/kern/subr_iostat.c:1.25	Wed May 22 08:47:02 2019
+++ src/sys/kern/subr_iostat.c	Sat May  4 13:33:18 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_iostat.c,v 1.25 2019/05/22 08:47:02 hannken Exp $	*/
+/*	$NetBSD: subr_iostat.c,v 1.26 2024/05/04 13:33:18 mlelstv Exp $	*/
 /*	NetBSD: subr_disk.c,v 1.69 2005/05/29 22:24:15 christos Exp	*/
 
 /*-
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.25 2019/05/22 08:47:02 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.26 2024/05/04 13:33:18 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -370,6 +370,8 @@ iostati_getnames(int disk_only, char *ol
 			memset(bf, 0, sizeof(bf));
 			if (first) {
 				strncpy(bf, stats->io_name, sizeof(bf));
+				/* account for trailing NUL byte */
+				needed += 1;
 				first = 0;
 			} else {
 				bf[0] = ' ';

Reply via email to