1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-07 16:25:01 +03:00

Fix bugs reported by Coverity Scan.

This commit is contained in:
Daiyuu Nobori
2018-09-28 22:39:38 +09:00
parent 06c06f1db8
commit ee9990317b
12 changed files with 29 additions and 15 deletions

View File

@ -9982,7 +9982,7 @@ char *DecryptPassword(BUF *b)
}
str = ZeroMalloc(b->Size + 1);
c = NewCrypt(key, sizeof(key));
c = NewCrypt(key, sizeof(key)); // NOTE by Daiyuu Nobori 2018-09-28: This is not a bug! Do not try to fix it!!
Encrypt(c, str, b->Buf, b->Size);
FreeCrypt(c);
@ -10028,7 +10028,7 @@ BUF *EncryptPassword(char *password)
size = StrLen(password) + 1;
tmp = ZeroMalloc(size);
c = NewCrypt(key, sizeof(key));
c = NewCrypt(key, sizeof(key)); // NOTE by Daiyuu Nobori 2018-09-28: This is not a bug! Do not try to fix it!!
Encrypt(c, tmp, password, size - 1);
FreeCrypt(c);

View File

@ -1579,7 +1579,7 @@ SEND_START:
{
// Packet data array
void **datas = MallocFast(sizeof(void *) * num_packet);
UINT *sizes = MallocFast(sizeof(UINT *) * num_packet);
UINT *sizes = MallocFast(sizeof(UINT) * num_packet);
UINT i;
i = 0;

View File

@ -3717,9 +3717,12 @@ bool HubPaPutPacket(SESSION *s, void *data, UINT size)
CancelList(s->CancelList);
// Yield
if (hub->Option != NULL && hub->Option->YieldAfterStorePacket)
if (hub != NULL)
{
YieldCpu();
if (hub->Option != NULL && hub->Option->YieldAfterStorePacket)
{
YieldCpu();
}
}
return true;

View File

@ -6011,7 +6011,7 @@ bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str)
{
// Compare posted data with the WaterMark
if ((data_size == StrLen(HTTP_VPN_TARGET_POSTDATA) && (Cmp(data, HTTP_VPN_TARGET_POSTDATA, data_size) == 0))
|| (Cmp(data, WaterMark, SizeOfWaterMark()) == 0))
|| ((data_size >= SizeOfWaterMark()) && Cmp(data, WaterMark, SizeOfWaterMark()) == 0))
{
// Check the WaterMark
Free(data);

View File

@ -2054,6 +2054,12 @@ UINT SiCalcPoint(SERVER *s, UINT num, UINT weight)
server_max_sessions = GetServerCapsInt(s, "i_max_sessions");
if (server_max_sessions == 0)
{
// Avoid divide by zero
server_max_sessions = 1;
}
return (UINT)(((double)server_max_sessions -
MIN((double)num * 100.0 / (double)weight, (double)server_max_sessions))
* (double)FARM_BASE_POINT / (double)server_max_sessions);

View File

@ -5307,7 +5307,7 @@ TCP_RESET:
seq64 = n->RecvSeq + (UINT64)seq - (n->RecvSeqInit + n->RecvSeq) % X32;
if ((n->RecvSeqInit + n->RecvSeq) % X32 > seq)
{
if (((n->RecvSeqInit + n->RecvSeq) % X32 - ack) >= 0x80000000)
if (((n->RecvSeqInit + n->RecvSeq) % X32 - seq) >= 0x80000000)
{
seq64 = n->RecvSeq + (UINT64)seq + X32 - (n->RecvSeqInit + n->RecvSeq) % X32;
}

View File

@ -1222,7 +1222,7 @@ static wchar_t *WpSecureNAT(WEBUI *wu, LIST *params)
// Get the enable / disable state of the current SecureNAT
{
RPC_HUB_STATUS t;
Zero(&t, sizeof(&t));
Zero(&t, sizeof(t));
StrCpy(t.HubName, sizeof(t.HubName), hubname);
retcode = StGetHubStatus(context->Admin, &t);
@ -1649,7 +1649,7 @@ static LIST *WuAnalyzeTarget(char *target,char *filename, UINT size)
while(*body != '=' && *body != '\0')
{
*body ++;
body++;
}
if(*body == '=')
{