From aac25f47b2a495d5be6d2b90269b30b29e0f691d Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 27 Oct 2014 07:40:37 -0700 Subject: [PATCH] hopefully fix the more serious ones --- .../ConnectionServer/src/shared/ConnectionServer.cpp | 2 +- .../soePlatform/ChatAPI/utils/UdpLibrary/UdpMisc.cpp | 10 ++++++---- external/3rd/library/udplibrary/UdpLibrary.cpp | 11 +++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp index 2f79f01f..b54d6340 100644 --- a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp +++ b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp @@ -229,7 +229,7 @@ bool ConnectionServer::decryptToken(const KeyShare::Token & token, char* session unsigned char * keyBuffer = new unsigned char[len + 1]; unsigned char * keyBufferPointer = keyBuffer; NOT_NULL(keyBuffer); - memset(keyBuffer, 0, sizeof(keyBuffer)); + memset(keyBuffer, 0, sizeof(*keyBuffer)); bool retval = cs.loginServerKeys->decipherToken(token, keyBuffer, len); diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/UdpLibrary/UdpMisc.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/UdpLibrary/UdpMisc.cpp index 755b6efb..08851ece 100644 --- a/external/3rd/library/soePlatform/ChatAPI/utils/UdpLibrary/UdpMisc.cpp +++ b/external/3rd/library/soePlatform/ChatAPI/utils/UdpLibrary/UdpMisc.cpp @@ -7,6 +7,8 @@ #include "UdpLogicalPacket.h" +#define LEFT_SHIFT(a, b) ((b) >= CHAR_BIT * sizeof(a)? 0 : (a) << (b)) + namespace UdpLibrary { @@ -87,10 +89,10 @@ int UdpMisc::Crc32(const void *buffer, int bufferLen, int encryptValue) 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D}; int crc = 0xffffffff; - crc = (crc >> 8 & 0x00FFFFFFL) ^ crc32_table[(crc ^ (encryptValue & 0xff)) & 0x000000FFL]; - crc = (crc >> 8 & 0x00FFFFFFL) ^ crc32_table[(crc ^ ((encryptValue >> 8) & 0xff)) & 0x000000FFL]; - crc = (crc >> 8 & 0x00FFFFFFL) ^ crc32_table[(crc ^ ((encryptValue >> 16) & 0xff)) & 0x000000FFL]; - crc = (crc >> 8 & 0x00FFFFFFL) ^ crc32_table[(crc ^ ((encryptValue >> 24) & 0xff)) & 0x000000FFL]; + crc = ((LEFT_SHIFT(crc, 8) & 0x00FFFFFFL)) ^ crc32_table[(crc ^ (encryptValue & 0xff)) & 0x000000FFL]; + crc = ((LEFT_SHIFT(crc, 8) & 0x00FFFFFFL)) ^ crc32_table[(crc ^ ((encryptValue >> 8) & 0xff)) & 0x000000FFL]; + crc = ((LEFT_SHIFT(crc, 8) & 0x00FFFFFFL)) ^ crc32_table[(crc ^ ((encryptValue >> 16) & 0xff)) & 0x000000FFL]; + crc = ((LEFT_SHIFT(crc, 8) & 0x00FFFFFFL)) ^ crc32_table[(crc ^ ((encryptValue >> 24) & 0xff)) & 0x000000FFL]; const udp_uchar *bufPtr = (const udp_uchar *)buffer; const udp_uchar *endPtr = (const udp_uchar *)buffer + bufferLen; diff --git a/external/3rd/library/udplibrary/UdpLibrary.cpp b/external/3rd/library/udplibrary/UdpLibrary.cpp index e52e8a46..c4b32c3b 100644 --- a/external/3rd/library/udplibrary/UdpLibrary.cpp +++ b/external/3rd/library/udplibrary/UdpLibrary.cpp @@ -6,6 +6,9 @@ #include "UdpLibrary.hpp" +#define LEFT_SHIFT(a, b) ((b) >= CHAR_BIT * sizeof(a)? 0 : (a) << (b)) + + #if defined(WIN32) #pragma warning(disable : 4710) #if defined(UDPLIBRARY_WINSOCK2) @@ -4178,10 +4181,10 @@ int UdpMisc::Crc32(const void *buffer, int bufferLen, int encryptValue) 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D}; int crc = 0xffffffff; - crc = (crc >> 8 & 0x00FFFFFFL) ^ crc32_table[(crc ^ (encryptValue & 0xff)) & 0x000000FFL]; - crc = (crc >> 8 & 0x00FFFFFFL) ^ crc32_table[(crc ^ ((encryptValue >> 8) & 0xff)) & 0x000000FFL]; - crc = (crc >> 8 & 0x00FFFFFFL) ^ crc32_table[(crc ^ ((encryptValue >> 16) & 0xff)) & 0x000000FFL]; - crc = (crc >> 8 & 0x00FFFFFFL) ^ crc32_table[(crc ^ ((encryptValue >> 24) & 0xff)) & 0x000000FFL]; + crc = ((LEFT_SHIFT(crc, 8) & 0x00FFFFFFL)) ^ crc32_table[(crc ^ (encryptValue & 0xff)) & 0x000000FFL]; + crc = ((LEFT_SHIFT(crc, 8) & 0x00FFFFFFL)) ^ crc32_table[(crc ^ ((encryptValue >> 8) & 0xff)) & 0x000000FFL]; + crc = ((LEFT_SHIFT(crc, 8) & 0x00FFFFFFL)) ^ crc32_table[(crc ^ ((encryptValue >> 16) & 0xff)) & 0x000000FFL]; + crc = ((LEFT_SHIFT(crc, 8) & 0x00FFFFFFL)) ^ crc32_table[(crc ^ ((encryptValue >> 24) & 0xff)) & 0x000000FFL]; const uchar *bufPtr = (const uchar *)buffer; const uchar *endPtr = (const uchar *)buffer + bufferLen;