Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet6 fix copyout() logic. more proper fix to be don...



details:   https://anonhg.NetBSD.org/src/rev/9dbe7f7c7bf8
branches:  trunk
changeset: 535465:9dbe7f7c7bf8
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Aug 19 23:14:39 2002 +0000

description:
fix copyout() logic.  more proper fix to be done on kame tree.

diffstat:

 sys/netinet6/nd6.c |  29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diffs (71 lines):

diff -r 4d1c43b2f3a8 -r 9dbe7f7c7bf8 sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c        Mon Aug 19 18:58:50 2002 +0000
+++ b/sys/netinet6/nd6.c        Mon Aug 19 23:14:39 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6.c,v 1.68 2002/08/19 07:23:22 itojun Exp $  */
+/*     $NetBSD: nd6.c,v 1.69 2002/08/19 23:14:39 itojun Exp $  */
 /*     $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $   */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.68 2002/08/19 07:23:22 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.69 2002/08/19 23:14:39 itojun Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1948,11 +1948,12 @@
 int
 nd6_sysctl(name, oldp, oldlenp, newp, newlen)
        int name;
-       void *oldp;
+       void *oldp;     /* syscall arg, need copyout */
        size_t *oldlenp;
-       void *newp;
+       void *newp;     /* syscall arg, need in */
        size_t newlen;
 {
+       void *p;
        size_t ol, l;
        int error;
 
@@ -1965,23 +1966,31 @@
                return EINVAL;
        ol = oldlenp ? *oldlenp : 0;
 
+       if (oldp) {
+               p = malloc(*oldlenp, M_TEMP, M_WAITOK);
+               if (!p)
+                       return ENOMEM;
+       } else
+               p = NULL;
        switch (name) {
        case ICMPV6CTL_ND6_DRLIST:
-               error = fill_drlist(oldp, oldlenp, ol);
-               if (!error && oldp)
-                       copyout(oldp, oldp, *oldlenp);
+               error = fill_drlist(p, oldlenp, ol);
+               if (!error && p && oldp)
+                       copyout(p, oldp, *oldlenp);
                break;
 
        case ICMPV6CTL_ND6_PRLIST:
-               error = fill_prlist(oldp, oldlenp, ol);
-               if (!error && oldp)
-                       copyout(oldp, oldp, *oldlenp);
+               error = fill_prlist(p, oldlenp, ol);
+               if (!error && p && oldp)
+                       copyout(p, oldp, *oldlenp);
                break;
 
        default:
                error = ENOPROTOOPT;
                break;
        }
+       if (p)
+               free(p, M_TEMP);
 
        return(error);
 }



Home | Main Index | Thread Index | Old Index