1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-12-27 18:49:53 +03:00

Merge PR #660: resolve several coverity issues

This commit is contained in:
Davide Beatrici 2018-08-19 21:01:46 +02:00 committed by GitHub
commit 45d2a3ef02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 453 deletions

View File

@ -267,18 +267,19 @@ int UnixEthOpenRawSocket()
// Is Ethernet device control supported?
bool IsEthSupported()
{
bool ret = false;
#if defined(UNIX_LINUX)
ret = IsEthSupportedLinux();
#if defined(UNIX_LINUX)
return IsEthSupportedLinux();
#elif defined(UNIX_SOLARIS)
ret = IsEthSupportedSolaris();
return IsEthSupportedSolaris();
#elif defined(BRIDGE_PCAP)
ret = true;
return true;
#elif defined(BRIDGE_BPF)
ret = true;
return true;
#else
return false;
#endif
return ret;
}
#ifdef UNIX_LINUX
@ -557,19 +558,19 @@ TOKEN_LIST *GetEthList()
}
TOKEN_LIST *GetEthListEx(UINT *total_num_including_hidden, bool enum_normal, bool enum_rawip)
{
TOKEN_LIST *t = NULL;
#if defined(UNIX_LINUX)
t = GetEthListLinux(enum_normal, enum_rawip);
return GetEthListLinux(enum_normal, enum_rawip);
#elif defined(UNIX_SOLARIS)
t = GetEthListSolaris();
return GetEthListSolaris();
#elif defined(BRIDGE_PCAP)
t = GetEthListPcap();
return GetEthListPcap();
#elif defined(BRIDGE_BPF)
t = GetEthListBpf();
return GetEthListBpf();
#else
return NULL;
#endif
return t;
}
#ifdef UNIX_LINUX
@ -1086,37 +1087,6 @@ bool DlipBindRequest(int fd)
return true;
}
// Attach to the device
bool DlipAttachRequest(int fd, UINT devid)
{
dl_attach_req_t req;
struct strbuf ctl;
int flags;
// Validate arguments
if (fd == -1)
{
return false;
}
Zero(&req, sizeof(req));
req.dl_primitive = DL_ATTACH_REQ;
req.dl_ppa = devid;
Zero(&ctl, sizeof(ctl));
ctl.maxlen = 0;
ctl.len = sizeof(req);
ctl.buf = (char *)&req;
flags = 0;
if (putmsg(fd, &ctl, NULL, flags) < 0)
{
return false;
}
return true;
}
// Verify the ACK message
bool DlipReceiveAck(int fd)
{
@ -1275,7 +1245,6 @@ ETH *OpenEthPcap(char *name, bool local, bool tapmode, char *tapaddr)
char errbuf[PCAP_ERRBUF_SIZE];
ETH *e;
pcap_t *p;
CANCEL *c;
// Validate arguments
if (name == NULL || tapmode != false)
@ -1525,19 +1494,19 @@ ETH *OpenEthBpf(char *name, bool local, bool tapmode, char *tapaddr)
// Open Ethernet adapter
ETH *OpenEth(char *name, bool local, bool tapmode, char *tapaddr)
{
ETH *ret = NULL;
#if defined(UNIX_LINUX)
ret = OpenEthLinux(name, local, tapmode, tapaddr);
#if defined(UNIX_LINUX)
return OpenEthLinux(name, local, tapmode, tapaddr);
#elif defined(UNIX_SOLARIS)
ret = OpenEthSolaris(name, local, tapmode, tapaddr);
return OpenEthSolaris(name, local, tapmode, tapaddr);
#elif defined(BRIDGE_PCAP)
ret = OpenEthPcap(name, local, tapmode, tapaddr);
return OpenEthPcap(name, local, tapmode, tapaddr);
#elif defined(BRIDGE_BPF)
ret = OpenEthBpf(name, local, tapmode, tapaddr);
return OpenEthBpf(name, local, tapmode, tapaddr);
#else
return NULL;
#endif
return ret;
}
typedef struct UNIXTHREAD
@ -2695,7 +2664,7 @@ void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
p = ParsePacket(data, size);
if (p->BroadcastPacket || Cmp(p->MacAddressDest, e->RawIpMyMacAddr, 6) == 0)
if (p && p->BroadcastPacket || Cmp(p->MacAddressDest, e->RawIpMyMacAddr, 6) == 0)
{
if (IsValidUnicastMacAddress(p->MacAddressSrc))
{

View File

@ -227,7 +227,6 @@ void EthSendIpPacketInnerIpRaw(ETH *e, void *data, UINT size, USHORT protocol);
#ifdef UNIX_SOLARIS
// Function prototype for Solaris
bool DlipAttachRequest(int fd, UINT devid);
bool DlipReceiveAck(int fd);
bool DlipPromiscuous(int fd, UINT level);
bool DlipBindRequest(int fd);

View File

@ -680,7 +680,6 @@ SOCK *CncNicInfo(UI_NICINFO *info)
{
SOCK *s;
PACK *p;
bool ret = false;
// Validate arguments
if (info == NULL)
{
@ -722,7 +721,6 @@ SOCK *CncMsgDlg(UI_MSG_DLG *dlg)
{
SOCK *s;
PACK *p;
bool ret = false;
char *utf;
// Validate arguments
if (dlg == NULL)
@ -763,29 +761,6 @@ void CndMsgDlgFree(SOCK *s)
ReleaseSock(s);
}
// The thread to stop the password input dialog client forcibly
void CncPasswordDlgHaltThread(THREAD *thread, void *param)
{
CNC_CONNECT_ERROR_DLG_THREAD_PARAM *dp = (CNC_CONNECT_ERROR_DLG_THREAD_PARAM *)param;
// Validate arguments
if (thread == NULL || param == NULL)
{
return;
}
while (true)
{
if (dp->Session->Halt || dp->HaltThread)
{
break;
}
Wait(dp->Event, 100);
}
Disconnect(dp->Sock);
}
// Show the password input dialog
bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg)
{
@ -1025,7 +1000,6 @@ SOCK *CncStatusPrinterWindowStart(SESSION *s)
// Send a string to the status indicator
void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str)
{
CNC_STATUS_PRINTER_WINDOW_PARAM *param;
PACK *p;
// Validate arguments
if (s == NULL || str == NULL)
@ -1033,8 +1007,6 @@ void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str)
return;
}
param = (CNC_STATUS_PRINTER_WINDOW_PARAM *)s->Param;
p = NewPack();
PackAddUniStr(p, "string", str);
SendPack(s, p);
@ -1124,41 +1096,6 @@ void CncReleaseSocket()
ReleaseSock(s);
}
// Get the Session ID of the client notification service
UINT CncGetSessionId()
{
SOCK *s = CncConnect();
PACK *p;
UINT ret;
if (s == NULL)
{
return INFINITE;
}
p = NewPack();
PackAddStr(p, "function", "get_session_id");
SendPack(s, p);
FreePack(p);
p = RecvPack(s);
if (p == NULL)
{
Disconnect(s);
ReleaseSock(s);
return INFINITE;
}
ret = PackGetInt(p, "session_id");
FreePack(p);
Disconnect(s);
ReleaseSock(s);
return ret;
}
// Terminate the process of the client notification service
void CncExit()
{
@ -2039,28 +1976,6 @@ bool CiHasAccountSensitiveInformation(BUF *b)
return ret;
}
bool CiHasAccountSensitiveInformationFile(wchar_t *name)
{
bool ret = false;
BUF *b;
// Validate arguments
if (name == NULL)
{
return false;
}
b = ReadDumpW(name);
if (b == NULL)
{
return false;
}
ret = CiHasAccountSensitiveInformation(b);
FreeBuf(b);
return ret;
}
// Delete the sensitive information in the account information
bool CiEraseSensitiveInAccount(BUF *b)
@ -4337,33 +4252,6 @@ void CiFreeEnumObjectInSecure(RPC_ENUM_OBJECT_IN_SECURE *a)
}
// RPC_ENUM_OBJECT_IN_SECURE
void InRpcEnumObjectInSecure(RPC_ENUM_OBJECT_IN_SECURE *e, PACK *p)
{
UINT i;
// Validate arguments
if (e == NULL || p == NULL)
{
return;
}
Zero(e, sizeof(RPC_ENUM_OBJECT_IN_SECURE));
e->NumItem = PackGetNum(p, "NumItem");
e->hWnd = PackGetInt(p, "hWnd");
e->ItemName = ZeroMalloc(sizeof(char *) * e->NumItem);
e->ItemType = ZeroMalloc(sizeof(bool) * e->NumItem);
for (i = 0;i < e->NumItem;i++)
{
char name[MAX_SIZE];
Zero(name, sizeof(name));
PackGetStrEx(p, "ItemName", name, sizeof(name), i);
e->ItemName[i] = CopyStr(name);
e->ItemType[i] = PackGetIntEx(p, "ItemType", i) ? true : false;
}
}
void OutRpcEnumObjectInSecure(PACK *p, RPC_ENUM_OBJECT_IN_SECURE *e)
{
UINT i;
@ -5125,29 +5013,6 @@ void OutRpcClientGetConnectionStatus(PACK *p, RPC_CLIENT_GET_CONNECTION_STATUS *
}
}
void InRpcClientNotify(RPC_CLIENT_NOTIFY *n, PACK *p)
{
// Validate arguments
if (n == NULL || p == NULL)
{
return;
}
Zero(n, sizeof(RPC_CLIENT_NOTIFY));
n->NotifyCode = PackGetInt(p, "NotifyCode");
}
void OutRpcClientNotify(PACK *p, RPC_CLIENT_NOTIFY *n)
{
// Validate arguments
if (n == NULL || p == NULL)
{
return;
}
PackAddInt(p, "NotifyCode", n->NotifyCode);
}
// Notification main
void CiNotifyMain(CLIENT *c, SOCK *s)
{
@ -5781,9 +5646,7 @@ REMOTE_CLIENT *CcConnectRpcEx(char *server_name, char *password, bool *bad_pass,
reg_port = 0;
}
}
#endif // OS_WIN32
port_start = CLIENT_CONFIG_PORT - 1;
if (reg_port != 0)
{
s = Connect(server_name, reg_port);
@ -5794,6 +5657,10 @@ REMOTE_CLIENT *CcConnectRpcEx(char *server_name, char *password, bool *bad_pass,
}
}
#endif // OS_WIN32
port_start = CLIENT_CONFIG_PORT - 1;
RETRY:
port_start++;
@ -6351,11 +6218,6 @@ bool CiCheckCertProc(SESSION *s, CONNECTION *c, X *server_x, bool *expired)
}
}
if (old_x != NULL)
{
FreeX(old_x);
}
return false;
#endif // OS_WIN32
}
@ -10470,35 +10332,6 @@ void CiWriteSettingToCfg(CLIENT *c, FOLDER *root)
}
}
// Create the inner VPN Server
SERVER *CiNewInnerVPNServer(CLIENT *c, bool relay_server)
{
SERVER *s = NULL;
// Validate arguments
if (c == NULL)
{
return NULL;
}
SetNatTLowPriority();
s = SiNewServerEx(false, true, relay_server);
return s;
}
// Stop the inner VPN Server
void CiFreeInnerVPNServer(CLIENT *c, SERVER *s)
{
// Validate arguments
if (c == NULL || s == NULL)
{
return;
}
SiReleaseServer(s);
}
// Apply settings of Inner VPN Server
void CiApplyInnerVPNServerConfig(CLIENT *c)
{
@ -10682,48 +10515,6 @@ CLIENT *CiNewClient()
return c;
}
// Examine whether two proxy server settings equal
bool CompareInternetSetting(INTERNET_SETTING *s1, INTERNET_SETTING *s2)
{
// Validate arguments
if (s1 == NULL || s2 == NULL)
{
return false;
}
if (s1->ProxyType != s2->ProxyType)
{
return false;
}
if (s1->ProxyType == PROXY_DIRECT)
{
return true;
}
if (s1->ProxyPort != s2->ProxyPort)
{
return false;
}
if (StrCmp(s1->ProxyHostName, s2->ProxyHostName) != 0)
{
return false;
}
if (StrCmp(s1->ProxyUsername, s2->ProxyUsername) != 0)
{
return false;
}
if (StrCmp(s1->ProxyPassword, s2->ProxyPassword) != 0)
{
return false;
}
return true;
}
// Send a global pulse
void CiSendGlobalPulse(CLIENT *c)
{
@ -10878,20 +10669,6 @@ void CiDecrementNumActiveSessions()
Unlock(ci_active_sessions_lock);
}
// Get the number of active sessions
UINT CiGetNumActiveSessions()
{
UINT ret;
Lock(ci_active_sessions_lock);
{
ret = ci_num_active_sessions;
}
Unlock(ci_active_sessions_lock);
return ret;
}
// Release the client
void CtReleaseClient(CLIENT *c)
{
@ -11061,19 +10838,6 @@ void CiCheckOs()
}
}
// Get the client object
CLIENT *CtGetClient()
{
if (client == NULL)
{
return NULL;
}
AddRef(client->ref);
return client;
}
// Client status indicator
void CiClientStatusPrinter(SESSION *s, wchar_t *status)
{

View File

@ -602,9 +602,6 @@ void CcSetServiceToForegroundProcess(REMOTE_CLIENT *r);
char *CiGetFirstVLan(CLIENT *c);
void CiNormalizeAccountVLan(CLIENT *c);
bool CompareInternetSetting(INTERNET_SETTING *s1, INTERNET_SETTING *s2);
void CnStart();
void CnListenerProc(THREAD *thread, void *param);
@ -646,7 +643,6 @@ SOCK *CncConnect();
SOCK *CncConnectEx(UINT timeout);
void CncReleaseSocket();
void CncExit();
UINT CncGetSessionId();
bool CncExecDriverInstaller(char *arg);
SOCK *CncStatusPrinterWindowStart(SESSION *s);
void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str);
@ -655,7 +651,6 @@ void CncStatusPrinterWindowThreadProc(THREAD *thread, void *param);
bool CncConnectErrorDlg(SESSION *session, UI_CONNECTERROR_DLG *dlg);
void CncConnectErrorDlgHaltThread(THREAD *thread, void *param);
bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg);
void CncPasswordDlgHaltThread(THREAD *thread, void *param);
void CncCheckCert(SESSION *session, UI_CHECKCERT *dlg);
void CncCheckCertHaltThread(THREAD *thread, void *param);
bool CncSecureSignDlg(SECURE_SIGN *sign);
@ -666,7 +661,6 @@ void CncNicInfoFree(SOCK *s);
void CtStartClient();
void CtStopClient();
CLIENT *CtGetClient();
void CtReleaseClient(CLIENT *c);
bool CtGetClientVersion(CLIENT *c, RPC_CLIENT_VERSION *ver);
bool CtGetCmSetting(CLIENT *c, CM_SETTING *s);
@ -797,13 +791,9 @@ bool CiTryToParseAccount(BUF *b);
bool CiTryToParseAccountFile(wchar_t *name);
bool CiEraseSensitiveInAccount(BUF *b);
bool CiHasAccountSensitiveInformation(BUF *b);
bool CiHasAccountSensitiveInformationFile(wchar_t *name);
void CiApplyInnerVPNServerConfig(CLIENT *c);
SERVER *CiNewInnerVPNServer(CLIENT *c, bool relay_server);
void CiFreeInnerVPNServer(CLIENT *c, SERVER *s);
void CiIncrementNumActiveSessions();
void CiDecrementNumActiveSessions();
UINT CiGetNumActiveSessions();
BUF *EncryptPassword(char *password);
BUF *EncryptPassword2(char *password);
@ -828,7 +818,6 @@ void InRpcClientEnumSecure(RPC_CLIENT_ENUM_SECURE *e, PACK *p);
void OutRpcClientEnumSecure(PACK *p, RPC_CLIENT_ENUM_SECURE *e);
void InRpcUseSecure(RPC_USE_SECURE *u, PACK *p);
void OutRpcUseSecure(PACK *p, RPC_USE_SECURE *u);
void InRpcEnumObjectInSecure(RPC_ENUM_OBJECT_IN_SECURE *e, PACK *p);
void OutRpcEnumObjectInSecure(PACK *p, RPC_ENUM_OBJECT_IN_SECURE *e);
void InRpcCreateVLan(RPC_CLIENT_CREATE_VLAN *v, PACK *p);
void OutRpcCreateVLan(PACK *p, RPC_CLIENT_CREATE_VLAN *v);
@ -858,8 +847,6 @@ void InRpcPolicy(POLICY *o, PACK *p);
void OutRpcPolicy(PACK *p, POLICY *o);
void InRpcClientGetConnectionStatus(RPC_CLIENT_GET_CONNECTION_STATUS *s, PACK *p);
void OutRpcClientGetConnectionStatus(PACK *p, RPC_CLIENT_GET_CONNECTION_STATUS *c);
void InRpcClientNotify(RPC_CLIENT_NOTIFY *n, PACK *p);
void OutRpcClientNotify(PACK *p, RPC_CLIENT_NOTIFY *n);
void InRpcClientConfig(CLIENT_CONFIG *c, PACK *p);
void OutRpcClientConfig(PACK *p, CLIENT_CONFIG *c);
void InRpcClientPasswordSetting(RPC_CLIENT_PASSWORD_SETTING *a, PACK *p);

View File

@ -549,6 +549,10 @@ bool CheckFileSystem()
FileClose(io);
b = ReadDumpW(filename);
if(b == NULL)
{
return false;
}
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
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())
{
@ -2012,7 +2016,7 @@ void TtcWorkerThread(THREAD *thread, void *param)
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);
@ -9370,8 +9374,10 @@ UINT PsCaps(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
{
LIST *o;
PS *ps = (PS *)param;
UINT ret = 0;
CAPSLIST *t;
UINT i;
CT *ct;
o = ParseCommandList(c, cmd_name, str, NULL, 0);
if (o == NULL)
@ -9382,56 +9388,43 @@ UINT PsCaps(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
// RPC call
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++)
{
CAPS *c = LIST_DATA(t->CapsList, i);
wchar_t title[MAX_SIZE];
char name[256];
for (i = 0;i < LIST_NUM(t->CapsList);i++)
Format(name, sizeof(name), "CT_%s", c->Name);
UniStrCpy(title, sizeof(title), _UU(name));
if (UniIsEmptyStr(title))
{
CAPS *c = LIST_DATA(t->CapsList, i);
wchar_t title[MAX_SIZE];
char name[256];
Format(name, sizeof(name), "CT_%s", c->Name);
UniStrCpy(title, sizeof(title), _UU(name));
if (UniIsEmptyStr(title))
{
UniFormat(title, sizeof(title), L"%S", (StrLen(c->Name) >= 2) ? c->Name + 2 : c->Name);
}
if (StartWith(c->Name, "b_"))
{
bool icon_pass = c->Value == 0 ? false : true;
if (StrCmpi(c->Name, "b_must_install_pcap") == 0)
{
// Reverse only item of WinPcap
icon_pass = !icon_pass;
}
CtInsert(ct, title, c->Value == 0 ? _UU("CAPS_NO") : _UU("CAPS_YES"));
}
else
{
wchar_t str[64];
UniToStru(str, c->Value);
CtInsert(ct, title, str);
}
UniFormat(title, sizeof(title), L"%S", (StrLen(c->Name) >= 2) ? c->Name + 2 : c->Name);
}
CtFree(ct, c);
if (StartWith(c->Name, "b_"))
{
bool icon_pass = c->Value == 0 ? false : true;
if (StrCmpi(c->Name, "b_must_install_pcap") == 0)
{
// Reverse only item of WinPcap
icon_pass = !icon_pass;
}
CtInsert(ct, title, c->Value == 0 ? _UU("CAPS_NO") : _UU("CAPS_YES"));
}
else
{
wchar_t str[64];
UniToStru(str, c->Value);
CtInsert(ct, title, str);
}
}
CtFree(ct, c);
FreeCapsList(t);
FreeParamValueList(o);
@ -10001,32 +9994,6 @@ bool CmdEvalNetworkAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param)
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
bool CmdEvalHostAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param)
@ -17131,7 +17098,7 @@ UINT64 StrToDateTime64(char *str)
ret = INFINITE;
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;
@ -19020,31 +18987,18 @@ UINT PsNatEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
}
else
{
bool ok = true;
t.UseNat = true;
if (ok == false)
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
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
{
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
ret = ScSetSecureNATOption(ps->Rpc, &t);
if (ret != ERR_NO_ERROR)
{
// An error has occured
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
}
}
FreeParamValueList(o);
@ -19088,31 +19042,18 @@ UINT PsNatDisable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
}
else
{
bool ok = true;
t.UseNat = false;
if (ok == false)
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
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
{
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
ret = ScSetSecureNATOption(ps->Rpc, &t);
if (ret != ERR_NO_ERROR)
{
// An error has occured
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
}
}
FreeParamValueList(o);
@ -19177,34 +19118,21 @@ UINT PsNatSet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
}
else
{
bool ok = true;
t.Mtu = GetParamInt(o, "MTU");
t.NatTcpTimeout = GetParamInt(o, "TCPTIMEOUT");
t.NatUdpTimeout = GetParamInt(o, "UDPTIMEOUT");
t.SaveLog = GetParamYes(o, "LOG");
if (ok == false)
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
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
{
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
ret = ScSetSecureNATOption(ps->Rpc, &t);
if (ret != ERR_NO_ERROR)
{
// An error has occured
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
}
}
FreeParamValueList(o);
@ -19497,31 +19425,18 @@ UINT PsDhcpEnable(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
}
else
{
bool ok = true;
t.UseDhcp = true;
if (ok == false)
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
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
{
StrCpy(t.HubName, sizeof(t.HubName), ps->HubName);
ret = ScSetSecureNATOption(ps->Rpc, &t);
if (ret != ERR_NO_ERROR)
{
// An error has occured
CmdPrintError(c, ret);
FreeParamValueList(o);
return ret;
}
}
}
FreeParamValueList(o);

View File

@ -342,7 +342,6 @@ bool CmdEvalTcpOrUdp(CONSOLE *c, wchar_t *str, void *param);
wchar_t *GetConnectionTypeStr(UINT type);
bool CmdEvalHostAndSubnetMask4(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 CmdEvalIpAndMask6(CONSOLE *c, wchar_t *str, void *param);
wchar_t *GetLogSwitchStr(UINT i);