Update some argument-documenting comments to match reality.
Add an explicit range check to those same arguments to reduce risk of cardiac arrest in future code readers.
This commit is contained in:
parent
0e7767264f
commit
df9de6c5cd
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user