From fade05f67f2c2791fe7112ca5041a84942b4d5de Mon Sep 17 00:00:00 2001 From: cube Date: Fri, 14 Jan 2005 00:25:12 +0000 Subject: [PATCH] As fd_lastfile might be negative, we can't use the (u_int) cast trick to compare fd and fdp->fd_lastfile in fdrelease(), so change the test to a more explicit one. Spotted by Matt Thomas. Should fix the panic reported by Matthias Scheler. --- sys/kern/kern_descrip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 584539d0672a..752f1a6805d1 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_descrip.c,v 1.128 2005/01/12 20:41:45 cube Exp $ */ +/* $NetBSD: kern_descrip.c,v 1.129 2005/01/14 00:25:12 cube Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.128 2005/01/12 20:41:45 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.129 2005/01/14 00:25:12 cube Exp $"); #include #include @@ -604,7 +604,7 @@ fdrelease(struct proc *p, int fd) fdp = p->p_fd; simple_lock(&fdp->fd_slock); - if ((u_int) fd > fdp->fd_lastfile) + if (fd < 0 || fd > fdp->fd_lastfile) goto badf; fpp = &fdp->fd_ofiles[fd]; fp = *fpp;