summaryrefslogtreecommitdiffstats
path: root/sys/kern/sysv_sem.c
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2001-09-10 11:36:08 +0000
committerdd <dd@FreeBSD.org>2001-09-10 11:36:08 +0000
commitafcc728682ca87b0c41d3b7e63d1ca05613c9f20 (patch)
treeb8d4aec29f844ee4271a6b1197409b35538af584 /sys/kern/sysv_sem.c
parentbd6f9cb9b63e7a70079067566e50b59abc81ce16 (diff)
downloadFreeBSD-src-afcc728682ca87b0c41d3b7e63d1ca05613c9f20.zip
FreeBSD-src-afcc728682ca87b0c41d3b7e63d1ca05613c9f20.tar.gz
Make the `nsops' variable in `semop' unsigned. This prevents an
overflow if uap->nsops (which is already unsigned) is over INT_MAX; consequently, the bounds check below becomes valid. Previously, if a value over INT_MAX was passed in uap->nsops, the bounds check wouldn't catch it, and the value would be used to compute copyin()'s third argument. Obtained from: NetBSD
Diffstat (limited to 'sys/kern/sysv_sem.c')
-rw-r--r--sys/kern/sysv_sem.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index ac32395..d18c98a 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -781,7 +781,7 @@ done2:
struct semop_args {
int semid;
struct sembuf *sops;
- int nsops;
+ u_int nsops;
};
#endif
@@ -794,7 +794,7 @@ semop(p, uap)
register struct semop_args *uap;
{
int semid = uap->semid;
- int nsops = uap->nsops;
+ u_int nsops = uap->nsops;
struct sembuf sops[MAX_SOPS];
register struct semid_ds *semaptr;
register struct sembuf *sopptr;
@@ -804,7 +804,7 @@ semop(p, uap)
int do_wakeup, do_undos;
#ifdef SEM_DEBUG
- printf("call to semop(%d, 0x%x, %d)\n", semid, sops, nsops);
+ printf("call to semop(%d, 0x%x, %u)\n", semid, sops, nsops);
#endif
mtx_lock(&Giant);
@@ -840,7 +840,7 @@ semop(p, uap)
if (nsops > MAX_SOPS) {
#ifdef SEM_DEBUG
- printf("too many sops (max=%d, nsops=%d)\n", MAX_SOPS, nsops);
+ printf("too many sops (max=%d, nsops=%u)\n", MAX_SOPS, nsops);
#endif
error = E2BIG;
goto done2;
@@ -848,7 +848,7 @@ semop(p, uap)
if ((error = copyin(uap->sops, &sops, nsops * sizeof(sops[0]))) != 0) {
#ifdef SEM_DEBUG
- printf("error = %d from copyin(%08x, %08x, %d)\n", error,
+ printf("error = %d from copyin(%08x, %08x, %u)\n", error,
uap->sops, &sops, nsops * sizeof(sops[0]));
#endif
goto done2;
OpenPOWER on IntegriCloud