Skip to content

Commit

Permalink
drop incoming udp packet with dst port = 0. it seems to be illegal
Browse files Browse the repository at this point in the history
based on RFC768.

commit for other OSes will follow.
  • Loading branch information
itojun committed Jan 7, 2000
1 parent dc43040 commit ffdd061
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kame/sys/netinet6/udp6_usrreq.c
Expand Up @@ -199,6 +199,10 @@ udp6_input(mp, offp, proto)
goto bad;
}

/* destination port of 0 is illegal, based on RFC768. */
if (uh->uh_dport == 0)
goto bad;

/* Be proactive about malicious use of IPv4 mapped address */
if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
Expand Down
12 changes: 12 additions & 0 deletions netbsd/sys/netinet/udp_usrreq.c
Expand Up @@ -218,6 +218,10 @@ udp_input(m, va_alist)
}
#endif

/* destination port of 0 is illegal, based on RFC768. */
if (uh->uh_dport == 0)
goto bad;

/*
* Make mbuf data length reflect UDP length.
* If not enough data to reflect UDP length, drop.
Expand Down Expand Up @@ -375,6 +379,10 @@ udp6_input(mp, offp, proto)
goto bad;
}

/* destination port of 0 is illegal, based on RFC768. */
if (uh->uh_dport == 0)
goto bad;

/* Be proactive about malicious use of IPv4 mapped address */
if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
Expand Down Expand Up @@ -926,6 +934,10 @@ udp_input(m, va_alist)
}
uh = (struct udphdr *)((caddr_t)ip + iphlen);

/* destination port of 0 is illegal, based on RFC768. */
if (uh->uh_dport == 0)
goto bad;

/*
* Make mbuf data length reflect UDP length.
* If not enough data to reflect UDP length, drop.
Expand Down

0 comments on commit ffdd061

Please sign in to comment.