vmstat: fix overflow of interrupt name buffer

sysctl() provides a count of number of bytes in the buffer.  That is the
actual buffer length.  Whereas looking for an interrupt entry with an
empty name could terminate too early, or overflow the end of the buffer.
The overflow will occur if the table of interrupt names is full.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36628
This commit is contained in:
Elliott Mitchell 2022-11-26 09:21:33 -07:00 committed by Konstantin Belousov
parent d4d7971849
commit e5c30ac930

View file

@ -1349,7 +1349,7 @@ dointr(unsigned int interval, int reps)
/* Determine the length of the longest interrupt name */
intrname = intrnames;
istrnamlen = strlen("interrupt");
while(*intrname != '\0') {
while (intrname < intrnames + inamlen) {
clen = strlen(intrname);
if (clen > istrnamlen)
istrnamlen = clen;