summaryrefslogtreecommitdiffstats
path: root/sys/netinet/udp_usrreq.c
diff options
context:
space:
mode:
authortholo <tholo@openbsd.org>1997-01-26 01:23:42 +0000
committertholo <tholo@openbsd.org>1997-01-26 01:23:42 +0000
commitadbc1e472823ca8bdc1d8c5e724ce4d51f733c97 (patch)
treec6aaa3cd80ba239bf5a4e1350d1b2df13c2546a8 /sys/netinet/udp_usrreq.c
parentuse mktemp(1) to avoid /tmp race; spotted by dholland@eecs.harvard.edu (diff)
downloadwireguard-openbsd-adbc1e472823ca8bdc1d8c5e724ce4d51f733c97.tar.xz
wireguard-openbsd-adbc1e472823ca8bdc1d8c5e724ce4d51f733c97.zip
Make ip_len and ip_off unsigned values; don't transmit or accept packets
larger than the maximum IP packet size. From NetBSD.
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r--sys/netinet/udp_usrreq.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index f78e4be2d7f..31bdf858ac9 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.7 1996/07/05 20:42:18 deraadt Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.8 1997/01/26 01:23:46 tholo Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -461,6 +461,15 @@ udp_output(m, va_alist)
}
/*
+ * Compute the packet length of the IP header, and
+ * punt if the length looks bogus.
+ */
+ if ((len + sizeof(struct udpiphdr)) > IP_MAXPACKET) {
+ error = EMSGSIZE;
+ goto release;
+ }
+
+ /*
* Fill in mbuf with extended UDP header
* and addresses and length put into network format.
*/