X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/2d21ac55c334faf3a56e5634905ed6987fc787d4..e2fac8b15b12a7979f72090454d850e612fc5b13:/bsd/kern/sysv_sem.c?ds=sidebyside diff --git a/bsd/kern/sysv_sem.c b/bsd/kern/sysv_sem.c index d244876ab..6c90d6485 100644 --- a/bsd/kern/sysv_sem.c +++ b/bsd/kern/sysv_sem.c @@ -1046,6 +1046,14 @@ semop(struct proc *p, struct semop_args *uap, register_t *retval) goto semopout; } + if (nsops < 0 || nsops > MAX_SOPS) { +#ifdef SEM_DEBUG + printf("too many sops (max=%d, nsops=%d)\n", MAX_SOPS, nsops); +#endif + eval = E2BIG; + goto semopout; + } + #if CONFIG_MACF /* * Initial pass thru sops to see what permissions are needed. @@ -1064,14 +1072,6 @@ semop(struct proc *p, struct semop_args *uap, register_t *retval) goto semopout; #endif - if (nsops < 0 || nsops > MAX_SOPS) { -#ifdef SEM_DEBUG - printf("too many sops (max=%d, nsops=%d)\n", MAX_SOPS, nsops); -#endif - eval = E2BIG; - goto semopout; - } - /* OK for LP64, since sizeof(struct sembuf) is currently invariant */ if ((eval = copyin(uap->sops, &sops, nsops * sizeof(struct sembuf))) != 0) { #ifdef SEM_DEBUG