summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrian <brian@openbsd.org>1998-01-04 20:29:21 +0000
committerbrian <brian@openbsd.org>1998-01-04 20:29:21 +0000
commit94aab8f8d6438a8cdd7267446380463ffadc2276 (patch)
treeee4899bffac355b0e82b74b17d1b84f31795e15c
parentsupport Trident TVGA9440 (diff)
downloadwireguard-openbsd-94aab8f8d6438a8cdd7267446380463ffadc2276.tar.xz
wireguard-openbsd-94aab8f8d6438a8cdd7267446380463ffadc2276.zip
Initialize CcpInfo protocols to -1 (none, not OUI).
Don't Call Term() for an algorithm that hasn't been Init()d.
-rw-r--r--usr.sbin/ppp/ccp.c26
-rw-r--r--usr.sbin/ppp/ccp.h5
2 files changed, 18 insertions, 13 deletions
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c
index 903c74f26e5..c0fb3e236f0 100644
--- a/usr.sbin/ppp/ccp.c
+++ b/usr.sbin/ppp/ccp.c
@@ -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.6 1997/12/24 09:30:23 brian Exp $
+ * $Id: ccp.c,v 1.7 1998/01/04 20:29:21 brian Exp $
*
* TODO:
* o Support other compression protocols
@@ -43,7 +43,7 @@
#include "pred.h"
#include "deflate.h"
-struct ccpstate CcpInfo;
+struct ccpstate CcpInfo = { -1, -1 };
static void CcpSendConfigReq(struct fsm *);
static void CcpSendTerminateReq(struct fsm *);
@@ -138,16 +138,14 @@ ReportCcpStatus(struct cmdargs const *arg)
static void
ccpstateInit(void)
{
- memset(&CcpInfo, '\0', sizeof CcpInfo);
- CcpInfo.his_proto = CcpInfo.my_proto = -1;
- if (in_algorithm >= 0 && in_algorithm < NALGORITHMS) {
+ if (CcpInfo.in_init)
(*algorithm[in_algorithm]->i.Term)();
- in_algorithm = -1;
- }
- if (out_algorithm >= 0 && out_algorithm < NALGORITHMS) {
+ if (CcpInfo.out_init)
(*algorithm[out_algorithm]->o.Term)();
- out_algorithm = -1;
- }
+ in_algorithm = -1;
+ out_algorithm = -1;
+ memset(&CcpInfo, '\0', sizeof CcpInfo);
+ CcpInfo.his_proto = CcpInfo.my_proto = -1;
}
void
@@ -245,10 +243,14 @@ CcpLayerUp(struct fsm *fp)
LogPrintf(LogCCP, "Out = %s[%d], In = %s[%d]\n",
protoname(CcpInfo.my_proto), CcpInfo.my_proto,
protoname(CcpInfo.his_proto), CcpInfo.his_proto);
- if (in_algorithm >= 0 && in_algorithm < NALGORITHMS)
+ if (!CcpInfo.in_init && in_algorithm >= 0 && in_algorithm < NALGORITHMS) {
(*algorithm[in_algorithm]->i.Init)();
- if (out_algorithm >= 0 && out_algorithm < NALGORITHMS)
+ CcpInfo.in_init = 1;
+ }
+ if (!CcpInfo.out_init && out_algorithm >= 0 && out_algorithm < NALGORITHMS) {
(*algorithm[out_algorithm]->o.Init)();
+ CcpInfo.out_init = 1;
+ }
}
void
diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h
index a184a8af397..732ccafc3db 100644
--- a/usr.sbin/ppp/ccp.h
+++ b/usr.sbin/ppp/ccp.h
@@ -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.2 1997/12/06 12:08:55 brian Exp $
+ * $Id: ccp.h,v 1.3 1998/01/04 20:29:22 brian Exp $
*
* TODO:
*/
@@ -42,6 +42,9 @@ struct ccpstate {
u_long his_reject; /* Request codes rejected by peer */
u_long my_reject; /* Request codes I have rejected */
+ int out_init; /* Init called for out algorithm */
+ int in_init; /* Init called for in algorithm */
+
u_long uncompout, compout;
u_long uncompin, compin;
};