--- i386/i386/sys_machdep.c.orig Fri Sep 8 11:27:00 2006 +++ i386/i386/sys_machdep.c Fri Sep 8 11:29:32 2006 @@ -504,7 +504,7 @@ i386_set_ldt(td, args) uap->start = NLDT; uap->num = MAX_LD - NLDT; } - if (uap->start <= LUDATA_SEL || uap->num <= 0) + if (uap->start <= LUDATA_SEL || uap->num == 0) return (EINVAL); mtx_lock_spin(&sched_lock); pldt = mdp->md_ldt; @@ -513,7 +513,7 @@ i386_set_ldt(td, args) return (0); } largest_ld = uap->start + uap->num; - if (largest_ld > pldt->ldt_len) + if (largest_ld > pldt->ldt_len || largest_ld < 0) largest_ld = pldt->ldt_len; i = largest_ld - uap->start; bzero(&((union descriptor *)(pldt->ldt_base))[uap->start], @@ -532,7 +532,7 @@ i386_set_ldt(td, args) /* verify range of descriptors to modify */ largest_ld = uap->start + uap->num; if (uap->start >= MAX_LD || - uap->num < 0 || largest_ld > MAX_LD) { + largest_ld < 0 || largest_ld > MAX_LD) { return (EINVAL); } }