From ad41d54b29dedf27d029e565b7875827e4253195 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 12 Aug 2018 16:03:10 +0500 Subject: [PATCH 1/7] src/Cedar/Command.c: remove logically dead code found by coverity --- src/Cedar/Command.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/Cedar/Command.c b/src/Cedar/Command.c index 7f380b33..2fbbddd5 100644 --- a/src/Cedar/Command.c +++ b/src/Cedar/Command.c @@ -19678,30 +19678,17 @@ UINT PsDhcpDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param) } else { - bool ok = true; - t.UseDhcp = false; - if (ok == false) + ret = ScSetSecureNATOption(ps->Rpc, &t); + + if (ret != ERR_NO_ERROR) { - // Parameter is invalid - ret = ERR_INVALID_PARAMETER; + // An error has occured CmdPrintError(c, ret); FreeParamValueList(o); return ret; } - else - { - ret = ScSetSecureNATOption(ps->Rpc, &t); - - if (ret != ERR_NO_ERROR) - { - // An error has occured - CmdPrintError(c, ret); - FreeParamValueList(o); - return ret; - } - } } FreeParamValueList(o); From 595245cd451877007a39ad3dddda50ae95b05780 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 12 Aug 2018 16:07:13 +0500 Subject: [PATCH 2/7] src/Cedar/IPsec_PPP.c: remove logically dead code found by coverity --- src/Cedar/IPsec_PPP.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Cedar/IPsec_PPP.c b/src/Cedar/IPsec_PPP.c index e95e68cb..cec8736a 100644 --- a/src/Cedar/IPsec_PPP.c +++ b/src/Cedar/IPsec_PPP.c @@ -2370,20 +2370,10 @@ PPP_LCP *ParseLCP(USHORT protocol, void *data, UINT size) Zero(&o, sizeof(o)); - // Type - if (len < 1) - { - goto LABEL_ERROR; - } o.Type = buf[0]; buf++; len--; - // Length - if (len < 1) - { - goto LABEL_ERROR; - } o.DataSize = buf[0]; if (o.DataSize < 2) { From e302cb5f749cd92dc3425ea8c5834680ae763324 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 12 Aug 2018 16:12:48 +0500 Subject: [PATCH 3/7] src/Cedar/IPsec_PPP.c: remove logically dead code found by coverity --- src/Cedar/IPsec_PPP.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Cedar/IPsec_PPP.c b/src/Cedar/IPsec_PPP.c index cec8736a..6721172a 100644 --- a/src/Cedar/IPsec_PPP.c +++ b/src/Cedar/IPsec_PPP.c @@ -2142,11 +2142,6 @@ PPP_PACKET *ParsePPPPacket(void *data, UINT size) buf = (UCHAR *)data; - // Address - if (size < 1) - { - goto LABEL_ERROR; - } if (buf[0] != 0xff) { goto LABEL_ERROR; From 981e8d0e7743c8d9ffcb3377808fca94c32ff15e Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 12 Aug 2018 16:15:53 +0500 Subject: [PATCH 4/7] src/Cedar/Protocol.c: remove logically dead code found by coverity --- src/Cedar/Protocol.c | 43 ++----------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/src/Cedar/Protocol.c b/src/Cedar/Protocol.c index d5919c3c..3d21257f 100644 --- a/src/Cedar/Protocol.c +++ b/src/Cedar/Protocol.c @@ -6112,51 +6112,12 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str) { // Root directory SERVER *s = c->Cedar->Server; - bool is_free = false; *error_detail_str = "HTTP_ROOT"; { - if (is_free == false) - { - // Other than free version - HttpSendForbidden(c->FirstSock, h->Target, ""); - } - else - { - // Free version - BUF *b = ReadDump("|free.htm"); - - if (b != NULL) - { - char *src = ZeroMalloc(b->Size + 1); - UINT dst_size = b->Size * 2 + 64; - char *dst = ZeroMalloc(dst_size); - char host[MAX_PATH]; - char portstr[64]; - - GetMachineName(host, sizeof(host)); - ToStr(portstr, c->FirstSock->LocalPort); - - Copy(src, b->Buf, b->Size); - ReplaceStrEx(dst, dst_size, src, - "$HOST$", host, false); - ReplaceStrEx(dst, dst_size, dst, - "$PORT$", portstr, false); - - FreeHttpHeader(h); - h = NewHttpHeader("HTTP/1.1", "202", "OK"); - AddHttpValue(h, NewHttpValue("Content-Type", HTTP_CONTENT_TYPE4)); - AddHttpValue(h, NewHttpValue("Connection", "Keep-Alive")); - AddHttpValue(h, NewHttpValue("Keep-Alive", HTTP_KEEP_ALIVE)); - PostHttp(c->FirstSock, h, dst, StrLen(dst)); - - Free(src); - Free(dst); - - FreeBuf(b); - } - } + // Other than free version + HttpSendForbidden(c->FirstSock, h->Target, ""); } } else From b8af87adc18b1c452f0701e50aa05bf7b9f448a4 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 12 Aug 2018 16:17:56 +0500 Subject: [PATCH 5/7] src/Cedar/Interop_OpenVPN.c: remove logically dead code found by coverity --- src/Cedar/Interop_OpenVPN.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Cedar/Interop_OpenVPN.c b/src/Cedar/Interop_OpenVPN.c index 151bd159..9d42c466 100644 --- a/src/Cedar/Interop_OpenVPN.c +++ b/src/Cedar/Interop_OpenVPN.c @@ -1623,11 +1623,6 @@ OPENVPN_PACKET *OvsParsePacket(UCHAR *data, UINT size) ret = ZeroMalloc(sizeof(OPENVPN_PACKET)); - // OpCode + KeyID - if (size < 1) - { - goto LABEL_ERROR; - } uc = *((UCHAR *)data); data++; size--; From 210352072866e00c9f14031b8fd213460fbf4a3a Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 12 Aug 2018 16:19:29 +0500 Subject: [PATCH 6/7] src/Cedar/Server.c: remove logically dead code found by coverity --- src/Cedar/Server.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Cedar/Server.c b/src/Cedar/Server.c index 5ec4ecba..51ede8e7 100644 --- a/src/Cedar/Server.c +++ b/src/Cedar/Server.c @@ -5766,7 +5766,6 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f) char tmp[MAX_SIZE]; X *x = NULL; K *k = NULL; - bool cluster_allowed = false; UINT num_connections_per_ip = 0; FOLDER *params_folder; UINT i; @@ -6028,13 +6027,8 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f) } Unlock(c->TrafficLock); - // Get whether the current license allows cluster mode - cluster_allowed = true; - - // Type of server - s->UpdatedServerType = s->ServerType = - cluster_allowed ? CfgGetInt(f, "ServerType") : SERVER_TYPE_STANDALONE; + s->UpdatedServerType = s->ServerType = CfgGetInt(f, "ServerType"); // Password if (CfgGetByte(f, "HashedPassword", s->HashedPassword, sizeof(s->HashedPassword)) != sizeof(s->HashedPassword)) From a7933800d0b17eeb1255e6ff43dcd78e03ec7341 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 12 Aug 2018 16:22:09 +0500 Subject: [PATCH 7/7] src/Cedar/Logging.c: remove logically dead code found by coverity --- src/Cedar/Logging.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Cedar/Logging.c b/src/Cedar/Logging.c index e25c4eb4..87330318 100644 --- a/src/Cedar/Logging.c +++ b/src/Cedar/Logging.c @@ -1145,14 +1145,7 @@ bool PacketLog(HUB *hub, SESSION *src_session, SESSION *dest_session, PKT *packe pl->Cedar = hub->Cedar; pl->Packet = p; pl->NoLog = no_log; - if (src_session != NULL) - { - pl->SrcSessionName = CopyStr(src_session->Name); - } - else - { - pl->SrcSessionName = CopyStr(""); - } + pl->SrcSessionName = CopyStr(src_session->Name); if (dest_session != NULL) { pl->DestSessionName = CopyStr(dest_session->Name);