Module Name: src
Committed By: maxv
Date: Thu Mar 22 09:04:25 UTC 2018
Modified Files:
src/sys/net/npf: npf_inet.c
Log Message:
Retrieve the complete IPv4 header right away, and make sure we did retrieve
the IPv6 option header we were iterating on.
To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/net/npf/npf_inet.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/net/npf/npf_inet.c
diff -u src/sys/net/npf/npf_inet.c:1.45 src/sys/net/npf/npf_inet.c:1.46
--- src/sys/net/npf/npf_inet.c:1.45 Thu Mar 22 08:57:47 2018
+++ src/sys/net/npf/npf_inet.c Thu Mar 22 09:04:25 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_inet.c,v 1.45 2018/03/22 08:57:47 maxv Exp $ */
+/* $NetBSD: npf_inet.c,v 1.46 2018/03/22 09:04:25 maxv Exp $ */
/*-
* Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_inet.c,v 1.45 2018/03/22 08:57:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_inet.c,v 1.46 2018/03/22 09:04:25 maxv Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -336,10 +336,15 @@ npf_cache_ip(npf_cache_t *npc, nbuf_t *n
return NPC_FMTERR;
}
- /* Check header length and fragment offset. */
+ /* Retrieve the complete header. */
if ((u_int)(ip->ip_hl << 2) < sizeof(struct ip)) {
return NPC_FMTERR;
}
+ ip = nbuf_ensure_contig(nbuf, (u_int)(ip->ip_hl << 2));
+ if (ip == NULL) {
+ return NPC_FMTERR;
+ }
+
if (ip->ip_off & ~htons(IP_DF | IP_RF)) {
/* Note fragmentation. */
flags |= NPC_IPFRAG;
@@ -424,6 +429,10 @@ npf_cache_ip(npf_cache_t *npc, nbuf_t *n
npc->npc_hlen += hlen;
}
+ if (ip6e == NULL) {
+ return NPC_FMTERR;
+ }
+
/*
* Re-fetch the header pointers (nbufs might have been
* reallocated). Restore the original offset (if any).