o Fix an obscure memory leak (if the peer sends PROTO_COMPD

packets when we haven't agreed a protocol).
o Move the complication of passing incoming data to the
  PROTO_COMPD input or dictionary setup routine into ccp.c
This commit is contained in:
Brian Somers 1998-02-18 19:36:13 +00:00
parent 63258dccc5
commit ee6c193f92
3 changed files with 27 additions and 32 deletions

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ccp.c,v 1.30.2.8 1998/02/08 11:04:45 brian Exp $
* $Id: ccp.c,v 1.30.2.9 1998/02/10 03:23:07 brian Exp $
*
* TODO:
* o Support other compression protocols
@ -452,23 +452,26 @@ CcpOutput(struct link *l, int pri, u_short proto, struct mbuf *m)
}
struct mbuf *
CompdInput(u_short *proto, struct mbuf *m)
ccp_Decompress(u_short *proto, struct mbuf *bp)
{
/* Decompress incoming data */
if (CcpInfo.reset_sent != -1) {
/* Send another REQ and put the packet in the bit bucket */
LogPrintf(LogCCP, "ReSendResetReq(%d)\n", CcpInfo.reset_sent);
FsmOutput(&CcpInfo.fsm, CODE_RESETREQ, CcpInfo.reset_sent, NULL, 0);
pfree(m);
} else if (CcpInfo.in_init)
return (*algorithm[CcpInfo.in_algorithm]->i.Read)(proto, m);
return NULL;
}
/*
* If proto isn't PROTO_COMPD, we still want to pass it to the
* decompression routines so that the dictionary's updated
*/
if (CcpInfo.fsm.state == ST_OPENED)
if (*proto == PROTO_COMPD) {
/* Decompress incoming data */
if (CcpInfo.reset_sent != -1) {
/* Send another REQ and put the packet in the bit bucket */
LogPrintf(LogCCP, "ReSendResetReq(%d)\n", CcpInfo.reset_sent);
FsmOutput(&CcpInfo.fsm, CODE_RESETREQ, CcpInfo.reset_sent, NULL, 0);
} else if (CcpInfo.in_init)
return (*algorithm[CcpInfo.in_algorithm]->i.Read)(proto, bp);
pfree(bp);
bp = NULL;
} else if ((*proto & 0xfff1) == 0x21 && CcpInfo.in_init)
/* Add incoming Network Layer traffic to our dictionary */
(*algorithm[CcpInfo.in_algorithm]->i.DictSetup)(*proto, bp);
void
CcpDictSetup(u_short proto, struct mbuf *m)
{
/* Add incoming data to the dictionary */
if (CcpInfo.in_init)
(*algorithm[CcpInfo.in_algorithm]->i.DictSetup)(proto, m);
return bp;
}

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ccp.h,v 1.14.2.7 1998/02/07 20:49:27 brian Exp $
* $Id: ccp.h,v 1.14.2.8 1998/02/08 11:04:49 brian Exp $
*
* TODO:
*/
@ -93,5 +93,4 @@ extern void CcpInit(struct bundle *, struct link *);
extern int ReportCcpStatus(struct cmdargs const *);
extern void CcpResetInput(u_char);
extern int CcpOutput(struct link *, int, u_short, struct mbuf *);
extern struct mbuf *CompdInput(u_short *, struct mbuf *);
extern void CcpDictSetup(u_short, struct mbuf *);
extern struct mbuf *ccp_Decompress(u_short *, struct mbuf *);

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: hdlc.c,v 1.28.2.10 1998/02/18 19:35:17 brian Exp $
* $Id: hdlc.c,v 1.28.2.11 1998/02/18 19:35:41 brian Exp $
*
* TODO:
*/
@ -364,16 +364,9 @@ DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp,
LogPrintf(LogDEBUG, "DecodePacket: proto = 0x%04x\n", proto);
/*
* If proto isn't PROTO_COMPD, we still want to pass it to the
* decompression routines so that the dictionary's updated
*/
if (CcpInfo.fsm.state == ST_OPENED)
if (proto == PROTO_COMPD) {
if ((bp = CompdInput(&proto, bp)) == NULL)
return;
} else if ((proto & 0xfff1) == 0x21) /* Network Layer protocol */
CcpDictSetup(proto, bp);
/* decompress everything. CCP needs uncompressed data too */
if ((bp = ccp_Decompress(&proto, bp)) == NULL)
return;
switch (proto) {
case PROTO_LCP: