From fde909e1a142f96c824cf2d2706a0d6dc363f488 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 21 Apr 2004 20:31:50 +0000 Subject: [PATCH] Add prototype for uiomove_frombuf. Change uiomove_frombuf to use size_t for its length argument (to be the same as uiomove). Remove code that dealt with length being negative. --- sys/kern/kern_subr.c | 19 +++++++------------ sys/sys/systm.h | 3 ++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index 1af80bf22ff7..d2fc8f43655e 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_subr.c,v 1.110 2004/04/21 18:40:38 itojun Exp $ */ +/* $NetBSD: kern_subr.c,v 1.111 2004/04/21 20:31:50 matt Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc. @@ -86,7 +86,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.110 2004/04/21 18:40:38 itojun Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.111 2004/04/21 20:31:50 matt Exp $"); #include "opt_ddb.h" #include "opt_md.h" @@ -207,24 +207,19 @@ uiomove(buf, n, uio) /* * Wrapper for uiomove() that validates the arguments against a known-good - * kernel buffer. Currently, uiomove accepts a signed (n) argument, which - * is almost definitely a bad thing, so we catch that here as well. We - * return a runtime failure, but it might be desirable to generate a runtime - * assertion failure instead. + * kernel buffer. */ int -uiomove_frombuf(void *buf, int buflen, struct uio *uio) +uiomove_frombuf(void *buf, size_t buflen, struct uio *uio) { - unsigned int offset, n; + size_t offset; if (uio->uio_offset < 0 || uio->uio_resid < 0 || (offset = uio->uio_offset) != uio->uio_offset) return (EINVAL); - if (buflen <= 0 || offset >= buflen) + if (offset >= buflen) return (0); - if ((n = buflen - offset) > INT_MAX) - return (EINVAL); - return (uiomove((char *)buf + offset, n, uio)); + return (uiomove((char *)buf + offset, buflen - offset, uio)); } /* diff --git a/sys/sys/systm.h b/sys/sys/systm.h index f27cee04041c..1e4e3373d6a9 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $NetBSD: systm.h,v 1.170 2004/01/23 05:01:19 simonb Exp $ */ +/* $NetBSD: systm.h,v 1.171 2004/04/21 20:31:50 matt Exp $ */ /*- * Copyright (c) 1982, 1988, 1991, 1993 @@ -344,6 +344,7 @@ int trace_enter __P((struct lwp *, register_t, register_t, void trace_exit __P((struct lwp *, register_t, void *, register_t [], int)); int uiomove __P((void *, size_t, struct uio *)); +int uiomove_frombuf __P((void *, size_t, struct uio *)); #ifdef _KERNEL int setjmp __P((label_t *));