1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-23 01:49:53 +03:00

Merge PR #643: resolve several issues found by coverity

This commit is contained in:
Davide Beatrici 2018-08-12 19:01:43 +02:00 committed by GitHub
commit 0a289debf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 93 deletions

View File

@ -19678,20 +19678,8 @@ UINT PsDhcpDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
} }
else else
{ {
bool ok = true;
t.UseDhcp = false; t.UseDhcp = false;
if (ok == false)
{
// Parameter is invalid
ret = ERR_INVALID_PARAMETER;
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
else
{
ret = ScSetSecureNATOption(ps->Rpc, &t); ret = ScSetSecureNATOption(ps->Rpc, &t);
if (ret != ERR_NO_ERROR) if (ret != ERR_NO_ERROR)
@ -19702,7 +19690,6 @@ UINT PsDhcpDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
return ret; return ret;
} }
} }
}
FreeParamValueList(o); FreeParamValueList(o);

View File

@ -2142,11 +2142,6 @@ PPP_PACKET *ParsePPPPacket(void *data, UINT size)
buf = (UCHAR *)data; buf = (UCHAR *)data;
// Address
if (size < 1)
{
goto LABEL_ERROR;
}
if (buf[0] != 0xff) if (buf[0] != 0xff)
{ {
goto LABEL_ERROR; goto LABEL_ERROR;
@ -2370,20 +2365,10 @@ PPP_LCP *ParseLCP(USHORT protocol, void *data, UINT size)
Zero(&o, sizeof(o)); Zero(&o, sizeof(o));
// Type
if (len < 1)
{
goto LABEL_ERROR;
}
o.Type = buf[0]; o.Type = buf[0];
buf++; buf++;
len--; len--;
// Length
if (len < 1)
{
goto LABEL_ERROR;
}
o.DataSize = buf[0]; o.DataSize = buf[0];
if (o.DataSize < 2) if (o.DataSize < 2)
{ {

View File

@ -1623,11 +1623,6 @@ OPENVPN_PACKET *OvsParsePacket(UCHAR *data, UINT size)
ret = ZeroMalloc(sizeof(OPENVPN_PACKET)); ret = ZeroMalloc(sizeof(OPENVPN_PACKET));
// OpCode + KeyID
if (size < 1)
{
goto LABEL_ERROR;
}
uc = *((UCHAR *)data); uc = *((UCHAR *)data);
data++; data++;
size--; size--;

View File

@ -1145,14 +1145,7 @@ bool PacketLog(HUB *hub, SESSION *src_session, SESSION *dest_session, PKT *packe
pl->Cedar = hub->Cedar; pl->Cedar = hub->Cedar;
pl->Packet = p; pl->Packet = p;
pl->NoLog = no_log; pl->NoLog = no_log;
if (src_session != NULL)
{
pl->SrcSessionName = CopyStr(src_session->Name); pl->SrcSessionName = CopyStr(src_session->Name);
}
else
{
pl->SrcSessionName = CopyStr("");
}
if (dest_session != NULL) if (dest_session != NULL)
{ {
pl->DestSessionName = CopyStr(dest_session->Name); pl->DestSessionName = CopyStr(dest_session->Name);

View File

@ -6112,52 +6112,13 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str)
{ {
// Root directory // Root directory
SERVER *s = c->Cedar->Server; SERVER *s = c->Cedar->Server;
bool is_free = false;
*error_detail_str = "HTTP_ROOT"; *error_detail_str = "HTTP_ROOT";
{
if (is_free == false)
{ {
// Other than free version // Other than free version
HttpSendForbidden(c->FirstSock, h->Target, ""); 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);
}
}
}
} }
else else
{ {

View File

@ -5766,7 +5766,6 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f)
char tmp[MAX_SIZE]; char tmp[MAX_SIZE];
X *x = NULL; X *x = NULL;
K *k = NULL; K *k = NULL;
bool cluster_allowed = false;
UINT num_connections_per_ip = 0; UINT num_connections_per_ip = 0;
FOLDER *params_folder; FOLDER *params_folder;
UINT i; UINT i;
@ -6028,13 +6027,8 @@ void SiLoadServerCfg(SERVER *s, FOLDER *f)
} }
Unlock(c->TrafficLock); Unlock(c->TrafficLock);
// Get whether the current license allows cluster mode
cluster_allowed = true;
// Type of server // Type of server
s->UpdatedServerType = s->ServerType = s->UpdatedServerType = s->ServerType = CfgGetInt(f, "ServerType");
cluster_allowed ? CfgGetInt(f, "ServerType") : SERVER_TYPE_STANDALONE;
// Password // Password
if (CfgGetByte(f, "HashedPassword", s->HashedPassword, sizeof(s->HashedPassword)) != sizeof(s->HashedPassword)) if (CfgGetByte(f, "HashedPassword", s->HashedPassword, sizeof(s->HashedPassword)) != sizeof(s->HashedPassword))