mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-23 01:49:53 +03:00
src/Cedar/Hub: resolve potential null pointer dereference, remove unused functions
found by coverity, cppcheck [src/Cedar/Hub.c:6663]: (style) The function 'CalcTrafficEntryDiff' is never used. [src/Cedar/Hub.c:3387]: (style) The function 'GetSessionByPtr' is never used. [src/Cedar/Hub.c:3139]: (style) The function 'SetSessionFirstRedirectHttpUrl' is never used. [src/Cedar/Hub.c:3912]: (style) The function 'VgsSetEmbTag' is never used. [src/Cedar/Hub.c:3918]: (style) The function 'VgsSetUserAgentValue' is never used.
This commit is contained in:
parent
50d96aae81
commit
83a8b5f4aa
116
src/Cedar/Hub.c
116
src/Cedar/Hub.c
@ -3023,7 +3023,7 @@ bool ApplyAccessListToStoredPacket(HUB *hub, SESSION *s, PKT *p)
|
|||||||
|
|
||||||
if (pass)
|
if (pass)
|
||||||
{
|
{
|
||||||
if (s != NULL && s->FirstTimeHttpRedirect && s->FirstTimeHttpAccessCheckIp != 0)
|
if (s->FirstTimeHttpRedirect && s->FirstTimeHttpAccessCheckIp != 0)
|
||||||
{
|
{
|
||||||
if ((p->TypeL3 == L3_IPV4 || p->TypeL3 == L3_IPV6) &&
|
if ((p->TypeL3 == L3_IPV4 || p->TypeL3 == L3_IPV6) &&
|
||||||
p->TypeL4 == L4_TCP)
|
p->TypeL4 == L4_TCP)
|
||||||
@ -3135,39 +3135,6 @@ bool IsTcpPacketNcsiHttpAccess(PKT *p)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the URL to which to redirect first
|
|
||||||
bool SetSessionFirstRedirectHttpUrl(SESSION *s, char *url)
|
|
||||||
{
|
|
||||||
URL_DATA d;
|
|
||||||
IP ip;
|
|
||||||
// Validate arguments
|
|
||||||
if (s == NULL || url == NULL || IsEmptyStr(url))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ParseUrl(&d, url, false, NULL) == false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrToIP(&ip, d.HostName) == false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsIP4(&ip) == false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
s->FirstTimeHttpAccessCheckIp = IPToUINT(&ip);
|
|
||||||
StrCpy(s->FirstTimeHttpRedirectUrl, sizeof(s->FirstTimeHttpRedirectUrl), url);
|
|
||||||
s->FirstTimeHttpRedirect = true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adding Access List
|
// Adding Access List
|
||||||
void AddAccessList(HUB *hub, ACCESS *a)
|
void AddAccessList(HUB *hub, ACCESS *a)
|
||||||
{
|
{
|
||||||
@ -3383,35 +3350,6 @@ UINT64 UsernameToInt64(char *name)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search the session from the session pointer
|
|
||||||
SESSION *GetSessionByPtr(HUB *hub, void *ptr)
|
|
||||||
{
|
|
||||||
// Validate arguments
|
|
||||||
if (hub == NULL || ptr == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
LockList(hub->SessionList);
|
|
||||||
{
|
|
||||||
UINT i;
|
|
||||||
for (i = 0;i < LIST_NUM(hub->SessionList);i++)
|
|
||||||
{
|
|
||||||
SESSION *s = LIST_DATA(hub->SessionList, i);
|
|
||||||
if (s == (SESSION *)ptr)
|
|
||||||
{
|
|
||||||
// Found
|
|
||||||
AddRef(s->ref);
|
|
||||||
UnlockList(hub->SessionList);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UnlockList(hub->SessionList);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search the session from the session name
|
// Search the session from the session name
|
||||||
SESSION *GetSessionByName(HUB *hub, char *name)
|
SESSION *GetSessionByName(HUB *hub, char *name)
|
||||||
{
|
{
|
||||||
@ -3908,26 +3846,6 @@ LABEL_TRY_AGAIN:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// VGS: Setting for embedding UA tag
|
|
||||||
void VgsSetEmbTag(bool b)
|
|
||||||
{
|
|
||||||
g_vgs_emb_tag = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
// VGS: Setting for the User-Agent value
|
|
||||||
void VgsSetUserAgentValue(char *str)
|
|
||||||
{
|
|
||||||
// Validate arguments
|
|
||||||
if (str == NULL || StrLen(str) != 8)
|
|
||||||
{
|
|
||||||
Zero(vgs_ua_str, sizeof(vgs_ua_str));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StrCpy(vgs_ua_str, sizeof(vgs_ua_str), str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking algorithm to prevent broadcast-storm
|
// Checking algorithm to prevent broadcast-storm
|
||||||
// If broadcast from a specific endpoint came frequently, filter it
|
// If broadcast from a specific endpoint came frequently, filter it
|
||||||
bool CheckBroadcastStorm(HUB *hub, SESSION *s, PKT *p)
|
bool CheckBroadcastStorm(HUB *hub, SESSION *s, PKT *p)
|
||||||
@ -3952,7 +3870,7 @@ bool CheckBroadcastStorm(HUB *hub, SESSION *s, PKT *p)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hub != NULL && hub->Option != NULL)
|
if (hub->Option != NULL)
|
||||||
{
|
{
|
||||||
strict = hub->Option->BroadcastLimiterStrictMode;
|
strict = hub->Option->BroadcastLimiterStrictMode;
|
||||||
no_heavy = hub->Option->DoNotSaveHeavySecurityLogs;
|
no_heavy = hub->Option->DoNotSaveHeavySecurityLogs;
|
||||||
@ -5621,7 +5539,7 @@ bool StorePacketFilterByPolicy(SESSION *s, PKT *p)
|
|||||||
|
|
||||||
hub = s->Hub;
|
hub = s->Hub;
|
||||||
|
|
||||||
if (hub->Option != NULL)
|
if (hub != NULL && hub->Option != NULL)
|
||||||
{
|
{
|
||||||
no_heavy = hub->Option->DoNotSaveHeavySecurityLogs;
|
no_heavy = hub->Option->DoNotSaveHeavySecurityLogs;
|
||||||
}
|
}
|
||||||
@ -6659,34 +6577,6 @@ void SetRadiusServerEx(HUB *hub, char *name, UINT port, char *secret, UINT inter
|
|||||||
Unlock(hub->RadiusOptionLock);
|
Unlock(hub->RadiusOptionLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the difference between the traffic data
|
|
||||||
void CalcTrafficEntryDiff(TRAFFIC_ENTRY *diff, TRAFFIC_ENTRY *old, TRAFFIC_ENTRY *current)
|
|
||||||
{
|
|
||||||
// Validate arguments
|
|
||||||
Zero(diff, sizeof(TRAFFIC_ENTRY));
|
|
||||||
if (old == NULL || current == NULL || diff == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current->BroadcastCount >= old->BroadcastCount)
|
|
||||||
{
|
|
||||||
diff->BroadcastCount = current->BroadcastCount - old->BroadcastCount;
|
|
||||||
}
|
|
||||||
if (current->BroadcastBytes >= old->BroadcastBytes)
|
|
||||||
{
|
|
||||||
diff->BroadcastBytes = current->BroadcastBytes - old->BroadcastBytes;
|
|
||||||
}
|
|
||||||
if (current->UnicastCount >= old->UnicastCount)
|
|
||||||
{
|
|
||||||
diff->UnicastCount = current->UnicastCount - old->UnicastCount;
|
|
||||||
}
|
|
||||||
if (current->UnicastBytes >= old->UnicastBytes)
|
|
||||||
{
|
|
||||||
diff->UnicastBytes = current->UnicastBytes - old->UnicastBytes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the traffic information for Virtual HUB
|
// Add the traffic information for Virtual HUB
|
||||||
void IncrementHubTraffic(HUB *h)
|
void IncrementHubTraffic(HUB *h)
|
||||||
{
|
{
|
||||||
|
@ -547,7 +547,6 @@ bool StorePacketFilter(SESSION *s, PKT *packet);
|
|||||||
void StorePacketToHubPa(HUB_PA *dest, SESSION *src, void *data, UINT size, PKT *packet, bool is_flooding, bool no_check_acl);
|
void StorePacketToHubPa(HUB_PA *dest, SESSION *src, void *data, UINT size, PKT *packet, bool is_flooding, bool no_check_acl);
|
||||||
void SetHubOnline(HUB *h);
|
void SetHubOnline(HUB *h);
|
||||||
void SetHubOffline(HUB *h);
|
void SetHubOffline(HUB *h);
|
||||||
SESSION *GetSessionByPtr(HUB *hub, void *ptr);
|
|
||||||
SESSION *GetSessionByName(HUB *hub, char *name);
|
SESSION *GetSessionByName(HUB *hub, char *name);
|
||||||
int CompareIpTable(void *p1, void *p2);
|
int CompareIpTable(void *p1, void *p2);
|
||||||
bool StorePacketFilterByPolicy(SESSION *s, PKT *p);
|
bool StorePacketFilterByPolicy(SESSION *s, PKT *p);
|
||||||
@ -566,7 +565,6 @@ void InitAccessList(HUB *hub);
|
|||||||
void FreeAccessList(HUB *hub);
|
void FreeAccessList(HUB *hub);
|
||||||
void AddAccessList(HUB *hub, ACCESS *a);
|
void AddAccessList(HUB *hub, ACCESS *a);
|
||||||
void AddAccessListEx(HUB *hub, ACCESS *a, bool no_sort, bool no_reassign_id);
|
void AddAccessListEx(HUB *hub, ACCESS *a, bool no_sort, bool no_reassign_id);
|
||||||
bool SetSessionFirstRedirectHttpUrl(SESSION *s, char *url);
|
|
||||||
bool IsTcpPacketNcsiHttpAccess(PKT *p);
|
bool IsTcpPacketNcsiHttpAccess(PKT *p);
|
||||||
UINT64 UsernameToInt64(char *name);
|
UINT64 UsernameToInt64(char *name);
|
||||||
void MakeSimpleUsernameRemoveNtDomain(char *dst, UINT dst_size, char *src);
|
void MakeSimpleUsernameRemoveNtDomain(char *dst, UINT dst_size, char *src);
|
||||||
@ -638,10 +636,7 @@ USERLIST *FindUserList(LIST *o, char *filename);
|
|||||||
bool IsUserMatchInUserList(LIST *o, char *filename, UINT64 user_hash);
|
bool IsUserMatchInUserList(LIST *o, char *filename, UINT64 user_hash);
|
||||||
bool IsUserMatchInUserListWithCacheExpires(LIST *o, char *filename, UINT64 user_hash, UINT64 lifetime);
|
bool IsUserMatchInUserListWithCacheExpires(LIST *o, char *filename, UINT64 user_hash, UINT64 lifetime);
|
||||||
bool IsUserMatchInUserListWithCacheExpiresAcl(LIST *o, char *name_in_acl, UINT64 user_hash, UINT64 lifetime);
|
bool IsUserMatchInUserListWithCacheExpiresAcl(LIST *o, char *name_in_acl, UINT64 user_hash, UINT64 lifetime);
|
||||||
void CalcTrafficEntryDiff(TRAFFIC_ENTRY *diff, TRAFFIC_ENTRY *old, TRAFFIC_ENTRY *current);
|
|
||||||
bool CheckMaxLoggedPacketsPerMinute(SESSION *s, UINT max_packets, UINT64 now);
|
bool CheckMaxLoggedPacketsPerMinute(SESSION *s, UINT max_packets, UINT64 now);
|
||||||
void VgsSetUserAgentValue(char *str);
|
|
||||||
void VgsSetEmbTag(bool b);
|
|
||||||
EAP_CLIENT *HubNewEapClient(CEDAR *cedar, char *hubname, char *client_ip_str, char *username);
|
EAP_CLIENT *HubNewEapClient(CEDAR *cedar, char *hubname, char *client_ip_str, char *username);
|
||||||
|
|
||||||
#endif // HUB_H
|
#endif // HUB_H
|
||||||
|
Loading…
Reference in New Issue
Block a user