fix assertions

This commit is contained in:
yamt 2011-04-25 22:04:32 +00:00
parent def46fd94a
commit e86be17a4f
2 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: in4_cksum.c,v 1.17 2008/02/12 13:05:55 joerg Exp $ */
/* $NetBSD: in4_cksum.c,v 1.18 2011/04/25 22:04:32 yamt Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in4_cksum.c,v 1.17 2008/02/12 13:05:55 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: in4_cksum.c,v 1.18 2011/04/25 22:04:32 yamt Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@ -50,14 +50,14 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, int off, int len)
uint32_t sum;
uint16_t *w;
if (nxt == 0)
return cpu_in_cksum(m, len, off, 0);
if (__predict_false(off < sizeof(struct ip)))
panic("in4_cksum: offset too short for IP header");
if (__predict_false(m->m_len < sizeof(struct ip)))
panic("in4_cksum: mbuf too short for IP header");
if (nxt == 0)
return cpu_in_cksum(m, len, off, 0);
/*
* Compute the equivalent of:
* struct ipovly ip;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_cksum.c,v 1.27 2008/03/10 22:34:40 yamt Exp $ */
/* $NetBSD: in6_cksum.c,v 1.28 2011/04/25 22:05:05 yamt Exp $ */
/*-
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_cksum.c,v 1.27 2008/03/10 22:34:40 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_cksum.c,v 1.28 2011/04/25 22:05:05 yamt Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@ -60,14 +60,14 @@ in6_cksum(struct mbuf *m, u_int8_t nxt, uint32_t off, uint32_t len)
const uint16_t *w;
const char *cp;
if (nxt == 0)
return cpu_in_cksum(m, len, off, 0);
if (__predict_false(off < sizeof(struct ip6_hdr)))
panic("in6_cksum: offset too short for IPv6 header");
if (__predict_false(m->m_len < sizeof(struct ip6_hdr)))
panic("in6_cksum: mbuf too short for IPv6 header");
if (nxt == 0)
return cpu_in_cksum(m, len, off, 0);
/*
* Compute the equivalent of:
* struct ip6_hdr_pseudo ip6;