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

src/Cedar/Command: remove dead code, null pointer dereference, unused functions, variables

found by coverity, cppcheck

[src/Cedar/Command.c:9378]: (style) Variable 'ret' is assigned a value that is never used.
[src/Cedar/Command.c:9999]: (style) The function 'CmdEvalNetworkAndSubnetMask6' is never used.
This commit is contained in:
Ilya Shipitsin 2018-08-18 17:55:24 +05:00
parent 0d966755d7
commit c4d1a10c2a
2 changed files with 60 additions and 146 deletions

View File

@ -549,6 +549,10 @@ bool CheckFileSystem()
FileClose(io); FileClose(io);
b = ReadDumpW(filename); b = ReadDumpW(filename);
if(b == NULL)
{
return false;
}
for (i = 0;i < b->Size;i++) for (i = 0;i < b->Size;i++)
{ {
@ -1335,7 +1339,7 @@ void TtsWorkerThread(THREAD *thread, void *param)
// Notice the size information from the server to the client // Notice the size information from the server to the client
tmp64 = Endian64(ts->NumBytes); tmp64 = Endian64(ts->NumBytes);
Recv(ts->Sock, recv_buf_data, buf_size, false); (void)Recv(ts->Sock, recv_buf_data, buf_size, false);
if (ts->LastWaitTick == 0 || ts->LastWaitTick <= Tick64()) if (ts->LastWaitTick == 0 || ts->LastWaitTick <= Tick64())
{ {
@ -2012,7 +2016,7 @@ void TtcWorkerThread(THREAD *thread, void *param)
suprise[i] = '!'; suprise[i] = '!';
} }
ret = Send(ts->Sock, suprise, sizeof(suprise), false); (void)Send(ts->Sock, suprise, sizeof(suprise), false);
} }
ret = Recv(ts->Sock, &tmp64, sizeof(tmp64), false); ret = Recv(ts->Sock, &tmp64, sizeof(tmp64), false);
@ -9370,8 +9374,10 @@ UINT PsCaps(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
{ {
LIST *o; LIST *o;
PS *ps = (PS *)param; PS *ps = (PS *)param;
UINT ret = 0;
CAPSLIST *t; CAPSLIST *t;
UINT i;
CT *ct;
o = ParseCommandList(c, cmd_name, str, NULL, 0); o = ParseCommandList(c, cmd_name, str, NULL, 0);
if (o == NULL) if (o == NULL)
@ -9382,18 +9388,6 @@ UINT PsCaps(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
// RPC call // RPC call
t = ScGetCapsEx(ps->Rpc); t = ScGetCapsEx(ps->Rpc);
if (ret != ERR_NO_ERROR)
{
// An error has occured
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
else
{
UINT i;
CT *ct;
ct = CtNewStandard(); ct = CtNewStandard();
for (i = 0;i < LIST_NUM(t->CapsList);i++) for (i = 0;i < LIST_NUM(t->CapsList);i++)
@ -9430,7 +9424,6 @@ UINT PsCaps(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
} }
CtFree(ct, c); CtFree(ct, c);
}
FreeCapsList(t); FreeCapsList(t);
@ -10001,32 +9994,6 @@ bool CmdEvalNetworkAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param)
return true; return true;
} }
bool CmdEvalNetworkAndSubnetMask6(CONSOLE *c, wchar_t *str, void *param)
{
char tmp[MAX_SIZE];
IP ip, mask;
// Validate arguments
if (c == NULL || str == NULL)
{
return false;
}
UniToStr(tmp, sizeof(tmp), str);
if (ParseIpAndSubnetMask6(tmp, &ip, &mask) == false)
{
c->Write(c, _UU("CMD_PARSE_IP_SUBNET_ERROR_1_6"));
return false;
}
if (IsNetworkPrefixAddress6(&ip, &mask) == false)
{
c->Write(c, _UU("CMD_PARSE_IP_SUBNET_ERROR_3"));
return false;
}
return true;
}
// Evaluate the IP address and subnet mask // Evaluate the IP address and subnet mask
bool CmdEvalHostAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param) bool CmdEvalHostAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param)
@ -17131,7 +17098,7 @@ UINT64 StrToDateTime64(char *str)
ret = INFINITE; ret = INFINITE;
if (a >= 1000 && a <= 9999 && b >= 1 && b <= 12 && c >= 1 && c <= 31 && if (a >= 1000 && a <= 9999 && b >= 1 && b <= 12 && c >= 1 && c <= 31 &&
d >= 0 && d <= 23 && e >= 0 && e <= 59 && f >= 0 && f <= 59) d <= 23 && e <= 59 && f <= 59)
{ {
SYSTEMTIME t; SYSTEMTIME t;
@ -19020,20 +18987,8 @@ UINT PsNatEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
} }
else else
{ {
bool ok = true;
t.UseNat = true; t.UseNat = true;
if (ok == false)
{
// Parameter is invalid
ret = ERR_INVALID_PARAMETER;
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
else
{
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName); StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
ret = ScSetSecureNATOption(ps->Rpc, &t); ret = ScSetSecureNATOption(ps->Rpc, &t);
@ -19045,7 +19000,6 @@ UINT PsNatEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
return ret; return ret;
} }
} }
}
FreeParamValueList(o); FreeParamValueList(o);
@ -19088,20 +19042,8 @@ UINT PsNatDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
} }
else else
{ {
bool ok = true;
t.UseNat = false; t.UseNat = false;
if (ok == false)
{
// Parameter is invalid
ret = ERR_INVALID_PARAMETER;
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
else
{
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName); StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
ret = ScSetSecureNATOption(ps->Rpc, &t); ret = ScSetSecureNATOption(ps->Rpc, &t);
@ -19113,7 +19055,6 @@ UINT PsNatDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
return ret; return ret;
} }
} }
}
FreeParamValueList(o); FreeParamValueList(o);
@ -19177,23 +19118,11 @@ UINT PsNatSet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
} }
else else
{ {
bool ok = true;
t.Mtu = GetParamInt(o, "MTU"); t.Mtu = GetParamInt(o, "MTU");
t.NatTcpTimeout = GetParamInt(o, "TCPTIMEOUT"); t.NatTcpTimeout = GetParamInt(o, "TCPTIMEOUT");
t.NatUdpTimeout = GetParamInt(o, "UDPTIMEOUT"); t.NatUdpTimeout = GetParamInt(o, "UDPTIMEOUT");
t.SaveLog = GetParamYes(o, "LOG"); t.SaveLog = GetParamYes(o, "LOG");
if (ok == false)
{
// Parameter is invalid
ret = ERR_INVALID_PARAMETER;
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
else
{
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName); StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
ret = ScSetSecureNATOption(ps->Rpc, &t); ret = ScSetSecureNATOption(ps->Rpc, &t);
@ -19205,7 +19134,6 @@ UINT PsNatSet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
return ret; return ret;
} }
} }
}
FreeParamValueList(o); FreeParamValueList(o);
@ -19497,20 +19425,8 @@ UINT PsDhcpEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
} }
else else
{ {
bool ok = true;
t.UseDhcp = true; t.UseDhcp = true;
if (ok == false)
{
// Parameter is invalid
ret = ERR_INVALID_PARAMETER;
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
else
{
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName); StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
ret = ScSetSecureNATOption(ps->Rpc, &t); ret = ScSetSecureNATOption(ps->Rpc, &t);
@ -19522,7 +19438,6 @@ UINT PsDhcpEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
return ret; return ret;
} }
} }
}
FreeParamValueList(o); FreeParamValueList(o);

View File

@ -342,7 +342,6 @@ bool CmdEvalTcpOrUdp(CONSOLE *c, wchar_t *str, void *param);
wchar_t *GetConnectionTypeStr(UINT type); wchar_t *GetConnectionTypeStr(UINT type);
bool CmdEvalHostAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param); bool CmdEvalHostAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param);
bool CmdEvalNetworkAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param); bool CmdEvalNetworkAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param);
bool CmdEvalNetworkAndSubnetMask6(CONSOLE *c, wchar_t *str, void *param);
bool CmdEvalIpAndMask4(CONSOLE *c, wchar_t *str, void *param); bool CmdEvalIpAndMask4(CONSOLE *c, wchar_t *str, void *param);
bool CmdEvalIpAndMask6(CONSOLE *c, wchar_t *str, void *param); bool CmdEvalIpAndMask6(CONSOLE *c, wchar_t *str, void *param);
wchar_t *GetLogSwitchStr(UINT i); wchar_t *GetLogSwitchStr(UINT i);