summaryrefslogtreecommitdiff
path: root/sys/kern/sysv_sem.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2006-08-10 17:03:49 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2006-08-10 17:03:49 +0000
commit0b9b4743dd4f186648f35e290f7163a081ea65d5 (patch)
tree9f5f71728f5429b0b70fcb12bf66354722b757e0 /sys/kern/sysv_sem.c
parent5e0a8a1779e59b35512a5528ea5790005789e769 (diff)
Fix a panic when more than the default number of sempahores are
allocated. Problem debugged by thib@
Diffstat (limited to 'sys/kern/sysv_sem.c')
-rw-r--r--sys/kern/sysv_sem.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index e62a3a95530..c680a97b928 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_sem.c,v 1.32 2004/07/15 11:24:46 millert Exp $ */
+/* $OpenBSD: sysv_sem.c,v 1.33 2006/08/10 17:03:48 millert Exp $ */
/* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */
/*
@@ -423,25 +423,23 @@ sys_semget(struct proc *p, void *v, register_t *retval)
if (key != IPC_PRIVATE) {
for (semid = 0, semaptr = NULL; semid < seminfo.semmni; semid++) {
if ((semaptr = sema[semid]) != NULL &&
- semaptr->sem_perm.key == key)
- break;
- }
- if (semaptr != NULL) {
- DPRINTF(("found public key\n"));
- if ((error = ipcperm(cred, &semaptr->sem_perm,
- semflg & 0700)))
- goto error;
- if (nsems > 0 && semaptr->sem_nsems < nsems) {
- DPRINTF(("too small\n"));
- error = EINVAL;
- goto error;
- }
- if ((semflg & IPC_CREAT) && (semflg & IPC_EXCL)) {
- DPRINTF(("not exclusive\n"));
- error = EEXIST;
- goto error;
+ semaptr->sem_perm.key == key) {
+ DPRINTF(("found public key\n"));
+ if ((error = ipcperm(cred, &semaptr->sem_perm,
+ semflg & 0700)))
+ goto error;
+ if (nsems > 0 && semaptr->sem_nsems < nsems) {
+ DPRINTF(("too small\n"));
+ error = EINVAL;
+ goto error;
+ }
+ if ((semflg & IPC_CREAT) && (semflg & IPC_EXCL)) {
+ DPRINTF(("not exclusive\n"));
+ error = EEXIST;
+ goto error;
+ }
+ goto found;
}
- goto found;
}
}