X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=modules%2Fvjcompress.c;h=eecbef5b35868589936692ce02783d0ac7da2546;hp=73a59d4986a61c816560d66de3a372116142f40d;hb=ca3cca0c7b8125832841f9f8e3183002e411168b;hpb=1bd5f1186d0bc87dc8383ac3395ef8935e5ba453 diff --git a/modules/vjcompress.c b/modules/vjcompress.c index 73a59d4..eecbef5 100644 --- a/modules/vjcompress.c +++ b/modules/vjcompress.c @@ -29,13 +29,13 @@ * This version is used under SunOS 4.x, DEC Alpha OSF/1, AIX 4.x, * and SVR4 systems including Solaris 2. * - * $Id: vjcompress.c,v 1.6 1995/05/29 06:33:55 paulus Exp $ + * $Id: vjcompress.c,v 1.8 1996/05/24 07:04:26 paulus Exp $ */ #include #include -#ifdef __svr4__ +#ifdef SVR4 #ifndef __GNUC__ #include /* for ntohl, etc. */ #else @@ -44,12 +44,12 @@ #endif #endif -#ifdef __osf__ +#ifdef OSF1 #include #endif #include -#ifdef __aix4__ +#ifdef AIX4 #define _NETINET_IN_SYSTM_H_ typedef u_long n_long; #else @@ -75,7 +75,7 @@ typedef u_long n_long; #define ovbcopy bcopy #endif -#ifdef __osf__ +#ifdef OSF1 #define getip_hl(base) (((base).ip_vhl)&0xf) #define getth_off(base) ((((base).th_xoff)&0xf0)>>4) @@ -430,8 +430,9 @@ vj_uncompress_err(comp) * "Uncompress" a packet of type TYPE_UNCOMPRESSED_TCP. */ int -vj_uncompress_uncomp(buf, comp) +vj_uncompress_uncomp(buf, buflen, comp) u_char *buf; + int buflen; struct vjcompress *comp; { register u_int hlen; @@ -439,7 +440,12 @@ vj_uncompress_uncomp(buf, comp) register struct ip *ip; ip = (struct ip *) buf; - if (ip->ip_p >= MAX_STATES) { + hlen = getip_hl(*ip) << 2; + if (ip->ip_p >= MAX_STATES + || hlen + sizeof(struct tcphdr) > buflen + || (hlen += getth_off(*((struct tcphdr *)&((char *)ip)[hlen])) << 2) + > buflen + || hlen > MAX_HDR) { comp->flags |= VJF_TOSS; INCR(vjs_errorin); return (0); @@ -447,9 +453,6 @@ vj_uncompress_uncomp(buf, comp) cs = &comp->rstate[comp->last_recv = ip->ip_p]; comp->flags &=~ VJF_TOSS; ip->ip_p = IPPROTO_TCP; - hlen = getip_hl(*ip); - hlen += getth_off(*((struct tcphdr *)&((int *)ip)[hlen])); - hlen <<= 2; BCOPY(ip, &cs->cs_ip, hlen); cs->cs_hlen = hlen; INCR(vjs_uncompressedin);