diff options
| author | Ed Maste <emaste@FreeBSD.org> | 2026-05-26 16:19:47 +0000 |
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2026-06-07 17:10:53 +0000 |
| commit | deaaddf1d3c4283649945553ad7e3208c8424308 (patch) | |
| tree | 55064449460c62173526ed89a098577a8ca4f059 /sys/dev/vt/vt_core.c | |
| parent | 95632c90ba32a55ec39a14ad7224a21d1c62c096 (diff) | |
vt: Avoid integer overflow in CONS_HISTORY ioctl
Reviewed by: markj, vexeduxr
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57250
(cherry picked from commit 0ae946e7223df5ef3f7980af1d774d7f593f6421)
Diffstat (limited to 'sys/dev/vt/vt_core.c')
| -rw-r--r-- | sys/dev/vt/vt_core.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 8360f0b80fb5..922b44028a23 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -40,6 +40,7 @@ #include <sys/kbio.h> #include <sys/kdb.h> #include <sys/kernel.h> +#include <sys/limits.h> #include <sys/linker.h> #include <sys/lock.h> #include <sys/malloc.h> @@ -2798,8 +2799,9 @@ skip_thunk: /* XXX */ return (0); case CONS_HISTORY: - if (*(int *)data < 0) - return EINVAL; + if (*(int *)data < 0 || + *(int *)data > UINT_MAX / USHRT_MAX / sizeof(term_char_t)) + return (EINVAL); if (*(int *)data != vw->vw_buf.vb_history_size) vtbuf_sethistory_size(&vw->vw_buf, *(int *)data); return (0); |
