summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/slcompress.c
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1996-04-11 08:14:44 +0000
committerdg <dg@FreeBSD.org>1996-04-11 08:14:44 +0000
commit7b2dcb887c3c20b2732bdc8ba43a11616680746b (patch)
treea9200deb9e62581560ff1de1c7fd4bc266df7d9f /usr.sbin/ppp/slcompress.c
parent4e39382a07fd0608835c8a29de5cc536033d9016 (diff)
downloadFreeBSD-src-7b2dcb887c3c20b2732bdc8ba43a11616680746b.zip
FreeBSD-src-7b2dcb887c3c20b2732bdc8ba43a11616680746b.tar.gz
Bugfix based on a kernel fix:
When PPP gets an uncompressed packet, it attempts to save off the TCP/IP header for use in decompressing subsequant packets. If PPP gets garbage (such as what happens when there is a port speed mismatch or modem line noise), it will occasionally mistake the packet as a valid uncompressed packet. When it tries to save off the header, it doesn't bother to check for the validity of the header length and will happily clobber not only the PPP VJC data structure, but parts of other process memory that happens to follow it...causing, ahem, undesired behavior.
Diffstat (limited to 'usr.sbin/ppp/slcompress.c')
-rw-r--r--usr.sbin/ppp/slcompress.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c
index dfabb0b..0e48d52 100644
--- a/usr.sbin/ppp/slcompress.c
+++ b/usr.sbin/ppp/slcompress.c
@@ -17,13 +17,13 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: slcompress.c,v 1.3 1995/05/30 03:50:57 rgrimes Exp $
+ * $Id: slcompress.c,v 1.4 1996/01/11 17:48:58 phk Exp $
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
*/
#ifndef lint
-static char const rcsid[] = "$Id$";
+static char const rcsid[] = "$Id: slcompress.c,v 1.4 1996/01/11 17:48:58 phk Exp $";
#endif
#include "defs.h"
@@ -430,10 +430,17 @@ sl_uncompress_tcp(bufp, len, type, comp)
cs = &comp->rstate[comp->last_recv = ip->ip_p];
comp->flags &=~ SLF_TOSS;
ip->ip_p = IPPROTO_TCP;
- hlen = ip->ip_hl;
+ /*
+ * Calculate the size of the TCP/IP header and make sure that
+ * we don't overflow the space we have available for it.
+ */
+ hlen = ip->ip_hl << 2;
+ if (hlen + sizeof(struct tcphdr) > len)
+ goto bad;
th = (struct tcphdr *)&((int *)ip)[hlen];
- hlen += THOFFSET(th);
- hlen <<= 2;
+ hlen += THOFFSET(th) << 2;
+ if (hlen > MAX_HDR)
+ goto bad;
BCOPY(ip, &cs->cs_ip, hlen);
cs->cs_ip.ip_sum = 0;
cs->cs_hlen = hlen;
OpenPOWER on IntegriCloud