From 76ae935172c791ae549313b02194d6e767506617 Mon Sep 17 00:00:00 2001 From: dnobori Date: Thu, 21 Nov 2019 23:26:36 +0100 Subject: [PATCH] Cedar: various fixes --- src/Cedar/Admin.c | 9 +++++++++ src/Cedar/Connection.c | 2 ++ src/Cedar/Hub.c | 2 +- src/Cedar/Logging.c | 2 +- src/Cedar/Proto_IKE.c | 4 ++-- src/Cedar/Proto_PPP.c | 2 +- src/Cedar/Radius.c | 7 ++++--- src/Cedar/Session.c | 4 ++-- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Cedar/Admin.c b/src/Cedar/Admin.c index f5e6ef56..c9714de5 100644 --- a/src/Cedar/Admin.c +++ b/src/Cedar/Admin.c @@ -9696,6 +9696,15 @@ UINT StSetFarmSetting(ADMIN *a, RPC_FARM *t) return ERR_NOT_SUPPORTED; } + if (IsZero(t->MemberPassword, sizeof(t->MemberPassword))) + { + if (IsEmptyStr(t->MemberPasswordPlaintext) == false) + { + // For JSON-RPC + HashAdminPassword(t->MemberPassword, t->MemberPasswordPlaintext); + } + } + ALog(a, NULL, "LA_SET_FARM_SETTING"); IncrementServerConfigRevision(a->Server); diff --git a/src/Cedar/Connection.c b/src/Cedar/Connection.c index ae8ddde4..8db61a7f 100644 --- a/src/Cedar/Connection.c +++ b/src/Cedar/Connection.c @@ -1160,6 +1160,8 @@ void ConnectionSend(CONNECTION *c, UINT64 now) s->TotalSendSizeReal += b->Size; c->CurrentSendQueueSize -= b->Size; + + Free(new_buf); } FreeBlock(b); diff --git a/src/Cedar/Hub.c b/src/Cedar/Hub.c index 02f2de14..0a37f8e0 100644 --- a/src/Cedar/Hub.c +++ b/src/Cedar/Hub.c @@ -5913,7 +5913,7 @@ void IntoTrafficLimiter(TRAFFIC_LIMITER *tr, PKT *p) } // Value increase - tr->Value += p->PacketSize * (UINT64)8; + tr->Value += (UINT64)p->PacketSize * (UINT64)8; } // The bandwidth reduction by traffic limiter diff --git a/src/Cedar/Logging.c b/src/Cedar/Logging.c index c172e6bf..1df57ce4 100644 --- a/src/Cedar/Logging.c +++ b/src/Cedar/Logging.c @@ -2181,7 +2181,7 @@ void MakeLogFileNameStringFromTick(LOG *g, char *str, UINT size, UINT64 tick, UI break; default: // Without switching - snprintf(str, size, "%s"); + StrCpy(str, size, ""); break; } diff --git a/src/Cedar/Proto_IKE.c b/src/Cedar/Proto_IKE.c index a5faa34d..c35468c2 100644 --- a/src/Cedar/Proto_IKE.c +++ b/src/Cedar/Proto_IKE.c @@ -2688,7 +2688,7 @@ IPSECSA *NewIPsecSa(IKE_SERVER *ike, IKE_CLIENT *c, IKE_SA *ike_sa, bool initiat // Set the expiration time if (setting->LifeSeconds != 0) { - UINT64 span = setting->LifeSeconds * (UINT64)1000 + (UINT64)IKE_SOFT_EXPIRES_MARGIN; + const UINT64 span = (UINT64)((UINT64)setting->LifeSeconds * (UINT64)1000) + (UINT64)IKE_SOFT_EXPIRES_MARGIN; sa->ExpiresHardTick = ike->Now + span; sa->ExpiresSoftTick = ike->Now + span; //sa->ExpiresSoftTick = ike->Now + (UINT64)5000; @@ -3740,7 +3740,7 @@ bool IkeIsVendorIdExists(IKE_PACKET *p, char *str) IKE_PACKET_PAYLOAD *payload = IkeGetPayload(p->PayloadList, IKE_PAYLOAD_VENDOR_ID, i); if (payload == NULL) { - return false; + break; } if (CompareBuf(payload->Payload.VendorId.Data, buf)) diff --git a/src/Cedar/Proto_PPP.c b/src/Cedar/Proto_PPP.c index 71ab6a33..e3e386bc 100644 --- a/src/Cedar/Proto_PPP.c +++ b/src/Cedar/Proto_PPP.c @@ -1215,7 +1215,7 @@ PPP_PACKET *PPPProcessRequestPacket(PPP_SESSION *p, PPP_PACKET *req) t = 1; } - p->DhcpRenewInterval = t * (UINT64)1000; + p->DhcpRenewInterval = (UINT64)t * (UINT64)1000; p->DhcpNextRenewTime = Tick64() + p->DhcpRenewInterval; if (true) diff --git a/src/Cedar/Radius.c b/src/Cedar/Radius.c index 864e3a0e..39cd4e9b 100644 --- a/src/Cedar/Radius.c +++ b/src/Cedar/Radius.c @@ -221,7 +221,7 @@ bool SendPeapRawPacket(EAP_CLIENT *e, UCHAR *peap_data, UINT peap_size) EAP_PEAP *send_peap_message; UINT sz; - sz = ReadBuf(buf, tmp, 200); + sz = ReadBuf(buf, tmp, sizeof(tmp)); if (sz == 0) { @@ -1856,10 +1856,11 @@ bool RadiusLogin(CONNECTION *c, char *server, UINT port, UCHAR *secret, UINT sec RadiusAddValue(p, RADIUS_ATTRIBUTE_SERVICE_TYPE, 0, 0, &ui, sizeof(ui)); // MS-RAS-Vendor - RadiusAddValue(p, RADIUS_ATTRIBUTE_VENDOR_SPECIFIC, RADIUS_VENDOR_MICROSOFT, RADIUS_MS_VERSION, ms_ras_version, StrLen(ms_ras_version)); + ui = Endian32(RADIUS_VENDOR_MICROSOFT); + RadiusAddValue(p, RADIUS_ATTRIBUTE_VENDOR_SPECIFIC, RADIUS_VENDOR_MICROSOFT, RADIUS_MS_RAS_VENDOR, &ui, sizeof(ui)); // MS-RAS-Version - RadiusAddValue(p, 26, 311, 18, ms_ras_version, StrLen(ms_ras_version)); + RadiusAddValue(p, RADIUS_ATTRIBUTE_VENDOR_SPECIFIC, RADIUS_VENDOR_MICROSOFT, RADIUS_MS_VERSION, ms_ras_version, StrLen(ms_ras_version)); // NAS-Port-Type ui = Endian32(5); diff --git a/src/Cedar/Session.c b/src/Cedar/Session.c index 88e96f2d..be03a7b1 100644 --- a/src/Cedar/Session.c +++ b/src/Cedar/Session.c @@ -103,7 +103,7 @@ void SessionMain(SESSION *s) s->LastCommTime = Tick64(); if (s->ServerMode == false) { - s->NextConnectionTime = Tick64() + s->ClientOption->AdditionalConnectionInterval * (UINT64)1000; + s->NextConnectionTime = Tick64() + (UINT64)((UINT64)s->ClientOption->AdditionalConnectionInterval * (UINT64)1000); } s->NumConnectionsEstablished++; @@ -900,7 +900,7 @@ void ClientAdditionalConnectChance(SESSION *s) (s->NextConnectionTime <= now)) { // Start the work to put an additional connection - s->NextConnectionTime = now + s->ClientOption->AdditionalConnectionInterval * (UINT64)1000U; + s->NextConnectionTime = now + ((UINT64)s->ClientOption->AdditionalConnectionInterval * (UINT64)1000); SessionAdditionalConnect(s); } else