diff options
author | brian <brian@cvs.openbsd.org> | 1997-12-28 02:16:35 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1997-12-28 02:16:35 +0000 |
commit | c23e03e32d1e3e01b558ffc174d07f7d8241716c (patch) | |
tree | c429bc6ddf6c160b42184945c9251519416d9de4 /usr.sbin/ppp/deflate.c | |
parent | a9dc2c9a85547e3103792e978400aae63a057930 (diff) |
Allow initial sequence numbers less than what we're expecting.
When CCP is originally negotiated, the only thing we can be
sure about is that we've started adding data to the inflate
dictionary either before or at the same time as the peer. This
is ok, 'cos DEFLATE is a `sliding window' compressor.
Diffstat (limited to 'usr.sbin/ppp/deflate.c')
-rw-r--r-- | usr.sbin/ppp/deflate.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c index dd63dc256e3..5ac759d60b3 100644 --- a/usr.sbin/ppp/deflate.c +++ b/usr.sbin/ppp/deflate.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: deflate.c,v 1.3 1997/12/21 14:27:01 brian Exp $ + * $Id: deflate.c,v 1.4 1997/12/28 02:16:34 brian Exp $ */ #include <sys/param.h> @@ -50,6 +50,7 @@ /* Our state */ struct deflate_state { u_short seqno; + int dodgy_seqno; z_stream cx; }; @@ -65,6 +66,7 @@ static void DeflateResetOutput(void) { OutputState.seqno = 0; + OutputState.dodgy_seqno = 0; deflateReset(&OutputState.cx); LogPrintf(LogCCP, "Deflate: Output channel reset\n"); } @@ -190,6 +192,7 @@ static void DeflateResetInput(void) { InputState.seqno = 0; + InputState.dodgy_seqno = 0; inflateReset(&InputState.cx); LogPrintf(LogCCP, "Deflate: Input channel reset\n"); } @@ -211,13 +214,18 @@ DeflateInput(u_short *proto, struct mbuf *mi) seq = (hdr[0] << 8) + hdr[1]; LogPrintf(LogDEBUG, "DeflateInput: Seq %d\n", seq); if (seq != InputState.seqno) { - LogPrintf(LogERROR, "DeflateInput: Seq error: Got %d, expected %d\n", - seq, InputState.seqno); - pfree(mi_head); - CcpSendResetReq(&CcpFsm); - return NULL; + if (InputState.dodgy_seqno && seq < InputState.seqno) + InputState.seqno = seq; + else { + LogPrintf(LogERROR, "DeflateInput: Seq error: Got %d, expected %d\n", + seq, InputState.seqno); + pfree(mi_head); + CcpSendResetReq(&CcpFsm); + return NULL; + } } InputState.seqno++; + InputState.dodgy_seqno = 0; /* Allocate an output mbuf */ mo_head = mo = mballoc(DEFLATE_CHUNK_LEN, MB_IPIN); @@ -525,6 +533,13 @@ DeflateInitInput(void) if (inflateInit2(&InputState.cx, -iWindowSize) != Z_OK) return 0; DeflateResetInput(); + /* + * When we begin, we may start adding to our dictionary before the + * peer does. If `dodgy_seqno' is set, we'll allow the peer to send + * us a seqno that's too small and just adjust seqno accordingly - + * deflate is a sliding window compressor ! + */ + InputState.dodgy_seqno = 1; return 1; } |