summaryrefslogtreecommitdiffstats
path: root/sys/net/if_gre.c
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2015-10-28 17:55:37 +0000
committerae <ae@FreeBSD.org>2015-10-28 17:55:37 +0000
commitf27a84317646769b581a8ee903a983af9306e6ec (patch)
tree7f06a75fac1ee68c6cc8ac864f64d78a73275513 /sys/net/if_gre.c
parent78fa4cdb3ca68cc791d70aa1e7194666ce617958 (diff)
downloadFreeBSD-src-f27a84317646769b581a8ee903a983af9306e6ec.zip
FreeBSD-src-f27a84317646769b581a8ee903a983af9306e6ec.tar.gz
Check the size of data available in mbuf, before using them.
PR: 202667 MFC after: 1 week
Diffstat (limited to 'sys/net/if_gre.c')
-rw-r--r--sys/net/if_gre.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index ffd94d8..24ed971 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -691,6 +691,14 @@ gre_input(struct mbuf **mp, int *offp, int proto)
KASSERT(sc != NULL, ("encap_getarg returned NULL"));
ifp = GRE2IFP(sc);
+ hlen = *offp + sizeof(struct grehdr) + 4 * sizeof(uint32_t);
+ if (m->m_pkthdr.len < hlen)
+ goto drop;
+ if (m->m_len < hlen) {
+ m = m_pullup(m, hlen);
+ if (m == NULL)
+ goto drop;
+ }
gh = (struct grehdr *)mtodo(m, *offp);
flags = ntohs(gh->gre_flags);
if (flags & ~GRE_FLAGS_MASK)
OpenPOWER on IntegriCloud