1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-23 01: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? // Is Ethernet device control supported?
bool IsEthSupported() bool IsEthSupported()
{ {
bool ret = false;
#if defined(UNIX_LINUX) #if defined(UNIX_LINUX)
ret = IsEthSupportedLinux(); return IsEthSupportedLinux();
#elif defined(UNIX_SOLARIS) #elif defined(UNIX_SOLARIS)
ret = IsEthSupportedSolaris(); return IsEthSupportedSolaris();
#elif defined(BRIDGE_PCAP) #elif defined(BRIDGE_PCAP)
ret = true; return true;
#elif defined(BRIDGE_BPF) #elif defined(BRIDGE_BPF)
ret = true; return true;
#else
return false;
#endif #endif
return ret;
} }
#ifdef UNIX_LINUX #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 *GetEthListEx(UINT *total_num_including_hidden, bool enum_normal, bool enum_rawip)
{ {
TOKEN_LIST *t = NULL;
#if defined(UNIX_LINUX) #if defined(UNIX_LINUX)
t = GetEthListLinux(enum_normal, enum_rawip); return GetEthListLinux(enum_normal, enum_rawip);
#elif defined(UNIX_SOLARIS) #elif defined(UNIX_SOLARIS)
t = GetEthListSolaris(); return GetEthListSolaris();
#elif defined(BRIDGE_PCAP) #elif defined(BRIDGE_PCAP)
t = GetEthListPcap(); return GetEthListPcap();
#elif defined(BRIDGE_BPF) #elif defined(BRIDGE_BPF)
t = GetEthListBpf(); return GetEthListBpf();
#else
return NULL;
#endif #endif
return t;
} }
#ifdef UNIX_LINUX #ifdef UNIX_LINUX
@ -1086,37 +1087,6 @@ bool DlipBindRequest(int fd)
return true; 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 // Verify the ACK message
bool DlipReceiveAck(int fd) bool DlipReceiveAck(int fd)
{ {
@ -1275,7 +1245,6 @@ ETH *OpenEthPcap(char *name, bool local, bool tapmode, char *tapaddr)
char errbuf[PCAP_ERRBUF_SIZE]; char errbuf[PCAP_ERRBUF_SIZE];
ETH *e; ETH *e;
pcap_t *p; pcap_t *p;
CANCEL *c;
// Validate arguments // Validate arguments
if (name == NULL || tapmode != false) if (name == NULL || tapmode != false)
@ -1525,19 +1494,19 @@ ETH *OpenEthBpf(char *name, bool local, bool tapmode, char *tapaddr)
// Open Ethernet adapter // Open Ethernet adapter
ETH *OpenEth(char *name, bool local, bool tapmode, char *tapaddr) ETH *OpenEth(char *name, bool local, bool tapmode, char *tapaddr)
{ {
ETH *ret = NULL;
#if defined(UNIX_LINUX) #if defined(UNIX_LINUX)
ret = OpenEthLinux(name, local, tapmode, tapaddr); return OpenEthLinux(name, local, tapmode, tapaddr);
#elif defined(UNIX_SOLARIS) #elif defined(UNIX_SOLARIS)
ret = OpenEthSolaris(name, local, tapmode, tapaddr); return OpenEthSolaris(name, local, tapmode, tapaddr);
#elif defined(BRIDGE_PCAP) #elif defined(BRIDGE_PCAP)
ret = OpenEthPcap(name, local, tapmode, tapaddr); return OpenEthPcap(name, local, tapmode, tapaddr);
#elif defined(BRIDGE_BPF) #elif defined(BRIDGE_BPF)
ret = OpenEthBpf(name, local, tapmode, tapaddr); return OpenEthBpf(name, local, tapmode, tapaddr);
#else
return NULL;
#endif #endif
return ret;
} }
typedef struct UNIXTHREAD typedef struct UNIXTHREAD
@ -2695,7 +2664,7 @@ void EthPutPacketLinuxIpRaw(ETH *e, void *data, UINT size)
p = ParsePacket(data, 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)) if (IsValidUnicastMacAddress(p->MacAddressSrc))
{ {

View File

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

View File

@ -680,7 +680,6 @@ SOCK *CncNicInfo(UI_NICINFO *info)
{ {
SOCK *s; SOCK *s;
PACK *p; PACK *p;
bool ret = false;
// Validate arguments // Validate arguments
if (info == NULL) if (info == NULL)
{ {
@ -722,7 +721,6 @@ SOCK *CncMsgDlg(UI_MSG_DLG *dlg)
{ {
SOCK *s; SOCK *s;
PACK *p; PACK *p;
bool ret = false;
char *utf; char *utf;
// Validate arguments // Validate arguments
if (dlg == NULL) if (dlg == NULL)
@ -763,29 +761,6 @@ void CndMsgDlgFree(SOCK *s)
ReleaseSock(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 // Show the password input dialog
bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg) bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg)
{ {
@ -1025,7 +1000,6 @@ SOCK *CncStatusPrinterWindowStart(SESSION *s)
// Send a string to the status indicator // Send a string to the status indicator
void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str) void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str)
{ {
CNC_STATUS_PRINTER_WINDOW_PARAM *param;
PACK *p; PACK *p;
// Validate arguments // Validate arguments
if (s == NULL || str == NULL) if (s == NULL || str == NULL)
@ -1033,8 +1007,6 @@ void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str)
return; return;
} }
param = (CNC_STATUS_PRINTER_WINDOW_PARAM *)s->Param;
p = NewPack(); p = NewPack();
PackAddUniStr(p, "string", str); PackAddUniStr(p, "string", str);
SendPack(s, p); SendPack(s, p);
@ -1124,41 +1096,6 @@ void CncReleaseSocket()
ReleaseSock(s); 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 // Terminate the process of the client notification service
void CncExit() void CncExit()
{ {
@ -2039,28 +1976,6 @@ bool CiHasAccountSensitiveInformation(BUF *b)
return ret; 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 // Delete the sensitive information in the account information
bool CiEraseSensitiveInAccount(BUF *b) bool CiEraseSensitiveInAccount(BUF *b)
@ -4337,33 +4252,6 @@ void CiFreeEnumObjectInSecure(RPC_ENUM_OBJECT_IN_SECURE *a)
} }
// RPC_ENUM_OBJECT_IN_SECURE // 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) void OutRpcEnumObjectInSecure(PACK *p, RPC_ENUM_OBJECT_IN_SECURE *e)
{ {
UINT i; 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 // Notification main
void CiNotifyMain(CLIENT *c, SOCK *s) void CiNotifyMain(CLIENT *c, SOCK *s)
{ {
@ -5781,9 +5646,7 @@ REMOTE_CLIENT *CcConnectRpcEx(char *server_name, char *password, bool *bad_pass,
reg_port = 0; reg_port = 0;
} }
} }
#endif // OS_WIN32
port_start = CLIENT_CONFIG_PORT - 1;
if (reg_port != 0) if (reg_port != 0)
{ {
s = Connect(server_name, reg_port); 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: RETRY:
port_start++; 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; return false;
#endif // OS_WIN32 #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 // Apply settings of Inner VPN Server
void CiApplyInnerVPNServerConfig(CLIENT *c) void CiApplyInnerVPNServerConfig(CLIENT *c)
{ {
@ -10682,48 +10515,6 @@ CLIENT *CiNewClient()
return c; 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 // Send a global pulse
void CiSendGlobalPulse(CLIENT *c) void CiSendGlobalPulse(CLIENT *c)
{ {
@ -10878,20 +10669,6 @@ void CiDecrementNumActiveSessions()
Unlock(ci_active_sessions_lock); 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 // Release the client
void CtReleaseClient(CLIENT *c) 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 // Client status indicator
void CiClientStatusPrinter(SESSION *s, wchar_t *status) void CiClientStatusPrinter(SESSION *s, wchar_t *status)
{ {

View File

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

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