Date: Mon, 25 Nov 2002 10:32:28 +0100 From: Olivier Houchard <cognet@ci0.org> To: freebsd-audit@FreeBSD.org Subject: do_dup patch Message-ID: <20021125093228.GA10213@ci0.org>
next in thread | raw e-mail | index | archive | help
--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi all,
This patch makes the "new" and "old" do_dup arguments unsigned int instead of
int. I can't see any reason they would have to be int, and right now a call to
dup or dup2 with an invalid negative fd, such as dup(-999999); will panic a
-CURRENT box (the problem doesn't exist on -STABLE because the file descriptor
validity is checked in dup() and dup2()).
Is there anything wrong with committing this ?
Any comments are welcome.
Olivier
--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kern_descrip.c.diff"
Index: kern_descrip.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_descrip.c,v
retrieving revision 1.168
diff -u -p -r1.168 kern_descrip.c
--- kern_descrip.c 27 Oct 2002 18:07:41 -0000 1.168
+++ kern_descrip.c 24 Nov 2002 19:52:55 -0000
@@ -101,7 +101,7 @@ static struct cdevsw fildesc_cdevsw = {
/* How to treat 'new' parameter when allocating a fd for do_dup(). */
enum dup_type { DUP_VARIABLE, DUP_FIXED };
-static int do_dup(struct thread *td, enum dup_type type, int old, int new,
+static int do_dup(struct thread *td, enum dup_type type, u_int old, u_int new,
register_t *retval);
static int badfo_readwrite(struct file *fp, struct uio *uio,
struct ucred *active_cred, int flags, struct thread *td);
@@ -171,8 +171,7 @@ dup2(td, uap)
struct dup2_args *uap;
{
- return (do_dup(td, DUP_FIXED, (int)uap->from, (int)uap->to,
- td->td_retval));
+ return (do_dup(td, DUP_FIXED, uap->from, uap->to, td->td_retval));
}
/*
@@ -193,7 +192,7 @@ dup(td, uap)
struct dup_args *uap;
{
- return (do_dup(td, DUP_VARIABLE, (int)uap->fd, 0, td->td_retval));
+ return (do_dup(td, DUP_VARIABLE, uap->fd, 0, td->td_retval));
}
/*
@@ -452,7 +451,7 @@ done2:
static int
do_dup(td, type, old, new, retval)
enum dup_type type;
- int old, new;
+ u_int old, new;
register_t *retval;
struct thread *td;
{
--Nq2Wo0NMKNjxTN9z--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021125093228.GA10213>
