Patch #1183 applied. This drops short UDP/TCP packets.

This commit is contained in:
likewise 2003-05-01 08:03:51 +00:00
parent 6c907ce8d1
commit 7cb64f2a43
2 changed files with 21 additions and 2 deletions

View File

@ -113,7 +113,16 @@ tcp_input(struct pbuf *p, struct netif *inp)
iphdr = p->payload;
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. */
if(ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask)) ||

View File

@ -175,7 +175,17 @@ udp_input(struct pbuf *p, struct netif *inp)
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);