From: provos Date: Sat, 1 Apr 2000 23:29:25 +0000 (+0000) Subject: fdup could fail when want for fdalloc > than the free fd in the block. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ac6915b0855bf01071277c01a416c4314c179a9e;p=openbsd fdup could fail when want for fdalloc > than the free fd in the block. slightly different fix than in the bug report by Rob Pickering --- diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 3f4e7396049..f3f15ed04de 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.19 2000/02/28 18:04:08 provos Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.20 2000/04/01 23:29:25 provos Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -619,6 +619,13 @@ fdalloc(p, want, result) i = find_next_zero(&fdp->fd_lomap[new], new > off ? 0 : i & NDENTRYMASK, NDENTRIES); + if (i == -1) { + /* free file descriptor in this block was + * below want, try again with higher want. + */ + want = (new + 1) << NDENTRYSHIFT; + continue; + } i += (new << NDENTRYSHIFT); if (i < last) { fd_used(fdp, i);