Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 Fix the ICMP error code. rh was obtained via IP...



details:   https://anonhg.NetBSD.org/src/rev/8283f34e9b46
branches:  trunk
changeset: 829456:8283f34e9b46
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Feb 01 16:17:00 2018 +0000

description:
Fix the ICMP error code. rh was obtained via IP6_EXTHDR_GET, and it is not
guaranteed to be in the same mbuf as ip6, so computing the difference
between the pointers may result in a wrong offset.

ip6 is now unused, so remove it.

diffstat:

 sys/netinet6/route6.c |  8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r f201ca5636a9 -r 8283f34e9b46 sys/netinet6/route6.c
--- a/sys/netinet6/route6.c     Thu Feb 01 15:53:16 2018 +0000
+++ b/sys/netinet6/route6.c     Thu Feb 01 16:17:00 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route6.c,v 1.23 2008/04/15 03:57:04 thorpej Exp $      */
+/*     $NetBSD: route6.c,v 1.24 2018/02/01 16:17:00 maxv Exp $ */
 /*     $KAME: route6.c,v 1.22 2000/12/03 00:54:00 itojun Exp $ */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route6.c,v 1.23 2008/04/15 03:57:04 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route6.c,v 1.24 2018/02/01 16:17:00 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -57,12 +57,10 @@
 int
 route6_input(struct mbuf **mp, int *offp, int proto)
 {
-       struct ip6_hdr *ip6;
        struct mbuf *m = *mp;
        struct ip6_rthdr *rh;
        int off = *offp, rhlen;
 
-       ip6 = mtod(m, struct ip6_hdr *);
        IP6_EXTHDR_GET(rh, struct ip6_rthdr *, m, off, sizeof(*rh));
        if (rh == NULL) {
                IP6_STATINC(IP6_STAT_TOOSHORT);
@@ -113,7 +111,7 @@
                }
                IP6_STATINC(IP6_STAT_BADOPTIONS);
                icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
-                           (char *)&rh->ip6r_type - (char *)ip6);
+                   off + offsetof(struct ip6_rthdr, ip6r_type));
                return (IPPROTO_DONE);
        }
 



Home | Main Index | Thread Index | Old Index