From ac6915b0855bf01071277c01a416c4314c179a9e Mon Sep 17 00:00:00 2001 From: provos Date: Sat, 1 Apr 2000 23:29:25 +0000 Subject: [PATCH] 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 --- sys/kern/kern_descrip.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); -- 2.20.1