diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -8582,8 +8582,11 @@ struct tcphdr *th = &pd->hdr.tcp; if (!pf_pull_hdr(m, *off, th, sizeof(*th), action, - reason, AF_INET)) + reason, AF_INET)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); + } *hdrlen = sizeof(*th); pd->p_len = pd->tot_len - *off - (th->th_off << 2); pd->sport = &th->th_sport; @@ -8594,8 +8597,11 @@ struct udphdr *uh = &pd->hdr.udp; if (!pf_pull_hdr(m, *off, uh, sizeof(*uh), action, - reason, AF_INET)) + reason, AF_INET)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); + } *hdrlen = sizeof(*uh); if (uh->uh_dport == 0 || ntohs(uh->uh_ulen) > m->m_pkthdr.len - *off || @@ -8611,6 +8617,8 @@ case IPPROTO_SCTP: { if (!pf_pull_hdr(m, *off, &pd->hdr.sctp, sizeof(pd->hdr.sctp), action, reason, AF_INET)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); } *hdrlen = sizeof(pd->hdr.sctp); @@ -8632,8 +8640,11 @@ } case IPPROTO_ICMP: { if (!pf_pull_hdr(m, *off, &pd->hdr.icmp, ICMP_MINLEN, - action, reason, AF_INET)) + action, reason, AF_INET)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); + } *hdrlen = ICMP_MINLEN; break; } @@ -8732,8 +8743,11 @@ struct tcphdr *th = &pd->hdr.tcp; if (!pf_pull_hdr(m, *off, th, sizeof(*th), action, - reason, AF_INET6)) + reason, AF_INET6)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); + } *hdrlen = sizeof(*th); pd->p_len = pd->tot_len - *off - (th->th_off << 2); pd->sport = &th->th_sport; @@ -8744,8 +8758,11 @@ struct udphdr *uh = &pd->hdr.udp; if (!pf_pull_hdr(m, *off, uh, sizeof(*uh), action, - reason, AF_INET6)) + reason, AF_INET6)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); + } *hdrlen = sizeof(*uh); if (uh->uh_dport == 0 || ntohs(uh->uh_ulen) > m->m_pkthdr.len - *off || @@ -8761,6 +8778,8 @@ case IPPROTO_SCTP: { if (!pf_pull_hdr(m, *off, &pd->hdr.sctp, sizeof(pd->hdr.sctp), action, reason, AF_INET6)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); } *hdrlen = sizeof(pd->hdr.sctp); @@ -8784,8 +8803,11 @@ size_t icmp_hlen = sizeof(struct icmp6_hdr); if (!pf_pull_hdr(m, *off, &pd->hdr.icmp6, icmp_hlen, - action, reason, AF_INET6)) + action, reason, AF_INET6)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); + } /* ICMP headers we look further into to match state */ switch (pd->hdr.icmp6.icmp6_type) { case MLD_LISTENER_QUERY: @@ -8799,8 +8821,11 @@ } if (icmp_hlen > sizeof(struct icmp6_hdr) && !pf_pull_hdr(m, *off, &pd->hdr.icmp6, icmp_hlen, - action, reason, AF_INET6)) + action, reason, AF_INET6)) { + *action = PF_DROP; + REASON_SET(reason, PFRES_SHORT); return (-1); + } *hdrlen = icmp_hlen; break; }