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:
nectar 2003-08-07 16:42:27 +00:00
parent 0e7767264f
commit df9de6c5cd
3 changed files with 9 additions and 6 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);