Module Name: src Committed By: christos Date: Sun Nov 30 18:15:41 UTC 2014
Modified Files: src/sys/netinet: in4_cksum.c Log Message: Only check that the offset < sizeof(struct ip) if nxt != 0, i.e. in the tcp and udp cases. From kre. XXX: pullup 7 To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/netinet/in4_cksum.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/netinet/in4_cksum.c diff -u src/sys/netinet/in4_cksum.c:1.19 src/sys/netinet/in4_cksum.c:1.20 --- src/sys/netinet/in4_cksum.c:1.19 Tue Mar 12 17:54:36 2013 +++ src/sys/netinet/in4_cksum.c Sun Nov 30 13:15:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: in4_cksum.c,v 1.19 2013/03/12 21:54:36 christos Exp $ */ +/* $NetBSD: in4_cksum.c,v 1.20 2014/11/30 18:15:41 christos Exp $ */ /*- * Copyright (c) 2008 Joerg Sonnenberger <jo...@netbsd.org>. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in4_cksum.c,v 1.19 2013/03/12 21:54:36 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in4_cksum.c,v 1.20 2014/11/30 18:15:41 christos Exp $"); #include <sys/param.h> #include <sys/mbuf.h> @@ -58,9 +58,6 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, uint32_t sum; uint16_t *w; - if (__predict_false(off < sizeof(struct ip))) - PANIC("%s: offset %d too short for IP header %zu", __func__, - off, sizeof(struct ip)); if (__predict_false(m->m_len < sizeof(struct ip))) PANIC("%s: mbuf %d too short for IP header %zu", __func__, m->m_len, sizeof(struct ip)); @@ -68,6 +65,10 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, if (nxt == 0) return cpu_in_cksum(m, len, off, 0); + if (__predict_false(off < sizeof(struct ip))) + PANIC("%s: offset %d too short for IP header %zu", __func__, + off, sizeof(struct ip)); + /* * Compute the equivalent of: * struct ipovly ip;