Skip to content

Commit 22d2c6b

Browse files
committed
Fix GRE de-tunneling
1 parent f047e0c commit 22d2c6b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pl7m.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,8 @@ static int dissect_l4(struct m_pkt *p)
599599
return -1;
600600
}
601601
/* Check version. 0 = GRE, 1 = ENHANCED GRE (used for PPTP) */
602-
if((gre_h->version != 0 && gre_h->version != 1) ||
603-
(gre_h->version == 1 && ntohs(gre_h->protocol) != 0x880b)) {
602+
if ((gre_h->version != 0 && gre_h->version != 1) ||
603+
(gre_h->version == 1 && ntohs(gre_h->protocol) != 0x880b)) {
604604
derr("Unexpected gre version %d\n", gre_h->version);
605605
return -1;
606606
}
@@ -627,12 +627,16 @@ static int dissect_l4(struct m_pkt *p)
627627
return -1;
628628
}
629629

630-
if(gre_h->version == 0) {
630+
if (gre_h->version == 0) {
631631
p->l3_proto = ntohs(gre_h->protocol);
632-
if(p->l3_proto == 0 && l4_hdr_len == p->l4_length) {
632+
if (p->l3_proto == 0 && l4_hdr_len == p->l4_length) {
633633
derr("GRE keepalive\n");
634634
return -1;
635635
}
636+
if (p->l3_proto != ETH_P_IP && p->l3_proto != ETH_P_IPV6) {
637+
derr("Invalid L3 after GRE: 0x%x\n", p->l3_proto);
638+
return -1;
639+
}
636640
} else {
637641
ppp_h = &data[l4_hdr_len];
638642

0 commit comments

Comments
 (0)