*/
/*
- * This version is used under SunOS 4.x, DEC Alpha OSF/1, AIX 4.x,
+ * This version is used under SunOS 4.x, Digital UNIX, AIX 4.x,
* and SVR4 systems including Solaris 2.
*
- * $Id: vjcompress.c,v 1.7 1995/12/11 02:57:49 paulus Exp $
+ * $Id: vjcompress.c,v 1.10 1999/09/15 23:49:06 masputra Exp $
*/
#include <sys/types.h>
#endif
#endif
-#ifdef OSF1
+#ifdef __osf__
#include <net/net_globals.h>
#endif
#include <netinet/in.h>
#define ovbcopy bcopy
#endif
-#ifdef OSF1
+#ifdef __osf__
#define getip_hl(base) (((base).ip_vhl)&0xf)
#define getth_off(base) ((((base).th_xoff)&0xf0)>>4)
* with it. */
goto uncompressed;
- if (deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) {
+ if ((deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) > 0) {
ENCODE(deltaS);
changes |= NEW_W;
}
- if (deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) {
+ if ((deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) > 0) {
if (deltaA > 0xffff)
goto uncompressed;
ENCODE(deltaA);
changes |= NEW_A;
}
- if (deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) {
+ if ((deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) > 0) {
if (deltaS > 0xffff)
goto uncompressed;
ENCODE(deltaS);
* "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;
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);
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);