diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index 51a0c5c39c0e..b138d98dc5d5 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -285,7 +285,7 @@ msgsys(td, uap) struct thread *td; /* XXX actually varargs. */ struct msgsys_args /* { - u_int which; + int which; int a2; int a3; int a4; @@ -297,7 +297,8 @@ msgsys(td, uap) if (!jail_sysvipc_allowed && jailed(td->td_ucred)) return (ENOSYS); - if (uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0])) + if (uap->which < 0 || + uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0])) return (EINVAL); error = (*msgcalls[uap->which])(td, &uap->a2); return (error); diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index 58e502d39a36..6ffe9c2b757a 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -275,7 +275,7 @@ semsys(td, uap) struct thread *td; /* XXX actually varargs. */ struct semsys_args /* { - u_int which; + int which; int a2; int a3; int a4; @@ -286,7 +286,8 @@ semsys(td, uap) if (!jail_sysvipc_allowed && jailed(td->td_ucred)) return (ENOSYS); - if (uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) + if (uap->which < 0 || + uap->which >= sizeof(semcalls)/sizeof(semcalls[0])) return (EINVAL); error = (*semcalls[uap->which])(td, &uap->a2); return (error); diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index a64c7f3093cf..7e9073b43528 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -784,7 +784,7 @@ shmsys(td, uap) struct thread *td; /* XXX actually varargs. */ struct shmsys_args /* { - u_int which; + int which; int a2; int a3; int a4; @@ -794,7 +794,8 @@ shmsys(td, uap) if (!jail_sysvipc_allowed && jailed(td->td_ucred)) return (ENOSYS); - if (uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0])) + if (uap->which < 0 || + uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0])) return (EINVAL); mtx_lock(&Giant); error = (*shmcalls[uap->which])(td, &uap->a2);