Module Name:    src
Committed By:   maxv
Date:           Thu Feb  1 16:17:00 UTC 2018

Modified Files:
        src/sys/netinet6: route6.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/netinet6/route6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/route6.c
diff -u src/sys/netinet6/route6.c:1.23 src/sys/netinet6/route6.c:1.24
--- src/sys/netinet6/route6.c:1.23	Tue Apr 15 03:57:04 2008
+++ src/sys/netinet6/route6.c	Thu Feb  1 16:17:00 2018
@@ -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 @@ static int ip6_rthdr0(struct mbuf *, str
 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 @@ route6_input(struct mbuf **mp, int *offp
 		}
 		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);
 	}
 

Reply via email to