Apply by doing: cd /usr/src patch -p0 < 002_semget.patch And then rebuild your kenel and reboot, e.g. cd sys/arch/`machine`/conf config GENERIC cd ../compile/GENERIC make depend bsd mv /bsd /bsd.old cp bsd / reboot Index: sys/kern/sysv_sem.c diff -u sys/kern/sysv_sem.c:1.16 sys/kern/sysv_sem.c:1.16.2.1 --- sys/kern/sysv_sem.c:1.16 Mon Jan 6 17:34:41 2003 +++ sys/kern/sysv_sem.c Wed Aug 20 14:16:41 2003 @@ -431,10 +431,20 @@ /* * Preallocate space for the new semaphore. If we are going - * to sleep, we want to sleep now to elliminate any race + * to sleep, we want to sleep now to eliminate any race * condition in allocating a semaphore with a specific key. */ if (key == IPC_PRIVATE || (semflg & IPC_CREAT)) { + if (nsems <= 0 || nsems > seminfo.semmsl) { + DPRINTF(("nsems out of range (0<%d<=%d)\n", nsems, + seminfo.semmsl)); + return (EINVAL); + } + if (nsems > seminfo.semmns - semtot) { + DPRINTF(("not enough semaphores left (need %d, got %d)\n", + nsems, seminfo.semmns - semtot)); + return (ENOSPC); + } semaptr_new = pool_get(&sema_pool, PR_WAITOK); semaptr_new->sem_base = malloc(nsems * sizeof(struct sem), M_SEM, M_WAITOK); @@ -468,18 +478,6 @@ DPRINTF(("need to allocate the semid_ds\n")); if (key == IPC_PRIVATE || (semflg & IPC_CREAT)) { - if (nsems <= 0 || nsems > seminfo.semmsl) { - DPRINTF(("nsems out of range (0<%d<=%d)\n", nsems, - seminfo.semmsl)); - error = EINVAL; - goto error; - } - if (nsems > seminfo.semmns - semtot) { - DPRINTF(("not enough semaphores left (need %d, got %d)\n", - nsems, seminfo.semmns - semtot)); - error = ENOSPC; - goto error; - } for (semid = 0; semid < seminfo.semmni; semid++) { if ((semaptr = sema[semid]) == NULL) break;
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: