In udp_output(), sanity check the length of the packet to be transmitted.

If it's larger than IP_MAXPACKET, return an error condition.
Based on a patch from Bill Fenner <fenner@parc.xerox.com>
This commit is contained in:
thorpej 1996-10-25 06:35:16 +00:00
parent 59bbc2199e
commit 096b0d6c6e
1 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: udp_usrreq.c,v 1.38 1996/10/16 19:33:39 ws Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.39 1996/10/25 06:35:16 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@ -449,6 +449,15 @@ udp_output(m, va_alist)
goto release;
}
/*
* 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.