1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39: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
{
bool ok = true;
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);
if (ret != ERR_NO_ERROR)
@ -19702,7 +19690,6 @@ UINT PsDhcpDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
return ret;
}
}
}
FreeParamValueList(o);

View File

@ -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;
@ -2370,20 +2365,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)
{

View File

@ -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--;

View File

@ -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("");
}
if (dest_session != NULL)
{
pl->DestSessionName = CopyStr(dest_session->Name);

View File

@ -6112,52 +6112,13 @@ 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);
}
}
}
}
else
{

View File

@ -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))