summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraaron <aaron@openbsd.org>2001-03-06 18:34:17 +0000
committeraaron <aaron@openbsd.org>2001-03-06 18:34:17 +0000
commit78f94e8245ff6a922743a948da4d8e117cd4d371 (patch)
tree71888f2b2a734e8635c5aed857bc85a82069d114
parentfix a kqueue related panic triggered by shutdown, okay art@ (diff)
downloadwireguard-openbsd-78f94e8245ff6a922743a948da4d8e117cd4d371.tar.xz
wireguard-openbsd-78f94e8245ff6a922743a948da4d8e117cd4d371.zip
Move the test for bogus packet length in udp_output() closer to the top of
the function. Previously it was possible for us to get stuck in splsoftnet() under certain situations. Bug reported by hunter@dg.net.ua, fix by me ok'd by deraadt@, provos@, angelos@.
-rw-r--r--sys/netinet/udp_usrreq.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 1f9319203f4..6f31222a7b0 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.54 2001/02/16 16:17:31 itojun Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.55 2001/03/06 18:34:17 aaron Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -887,6 +887,15 @@ udp_output(m, va_alist)
panic("IPv6 inpcb to udp_output");
#endif
+ /*
+ * 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;
+ }
+
if (addr) {
/*
* Save current PCB flags because they may change during
@@ -925,15 +934,6 @@ 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.
*/