mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00
Patch #1183 applied. This drops short UDP/TCP packets.
This commit is contained in:
parent
6c907ce8d1
commit
7cb64f2a43
@ -113,7 +113,16 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
iphdr = p->payload;
|
iphdr = p->payload;
|
||||||
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
|
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
|
||||||
|
|
||||||
pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4)));
|
if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4)))) {
|
||||||
|
/* drop short packets */
|
||||||
|
DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%u bytes) discarded\n", p->tot_len));
|
||||||
|
#ifdef TCP_STATS
|
||||||
|
++lwip_stats.tcp.lenerr;
|
||||||
|
++lwip_stats.tcp.drop;
|
||||||
|
#endif /* TCP_STATS */
|
||||||
|
pbuf_free(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Don't even process incoming broadcasts/multicasts. */
|
/* Don't even process incoming broadcasts/multicasts. */
|
||||||
if(ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask)) ||
|
if(ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask)) ||
|
||||||
|
@ -175,7 +175,17 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
|
|
||||||
iphdr = p->payload;
|
iphdr = p->payload;
|
||||||
|
|
||||||
pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)));
|
if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) {
|
||||||
|
/* drop short packets */
|
||||||
|
DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len));
|
||||||
|
#ifdef UDP_STATS
|
||||||
|
++lwip_stats.udp.lenerr;
|
||||||
|
++lwip_stats.udp.drop;
|
||||||
|
#endif /* UDP_STATS */
|
||||||
|
snmp_inc_udpinerrors();
|
||||||
|
pbuf_free(p);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN);
|
udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user