From 15dddc77013f5366b77a73ca02f58680eaef9736 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 2 Jan 2014 18:08:38 +0100 Subject: More memory alignment fixes. Ref.: #420. --- src/Protocol/Protocol132.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Protocol/Protocol132.cpp') diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 346607b79..46ac4ef89 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -886,15 +886,15 @@ void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const A time_t CurTime = time(NULL); CryptoPP::RandomPool rng; rng.Put((const byte *)&CurTime, sizeof(CurTime)); - byte DecryptedNonce[MAX_ENC_LEN]; - DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), DecryptedNonce); + Int32 DecryptedNonce[MAX_ENC_LEN / sizeof(Int32)]; + DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), (byte *)DecryptedNonce); if (!res.isValidCoding || (res.messageLength != 4)) { LOGD("Bad nonce length"); m_Client->Kick("Hacked client"); return; } - if (ntohl(*((int *)DecryptedNonce)) != (unsigned)(uintptr_t)this) + if (ntohl(DecryptedNonce[0]) != (unsigned)(uintptr_t)this) { LOGD("Bad nonce value"); m_Client->Kick("Hacked client"); -- cgit v1.2.3 From 2dbe5033ca30ce791e3cb28cc59f47d52225b7ae Mon Sep 17 00:00:00 2001 From: Diusrex Date: Sun, 5 Jan 2014 15:06:17 -0700 Subject: Added warning(push) and warning(pop) around all of the inclusions of cryptopp/*.h I also added a warning(push)/(pop) around crpytlib.cpp because it would go crazy with warnings. So now, the only warning from cryptopp that is not blocked is 'unreferenced local function has been removed', which also occurs at a single function. --- src/Protocol/Protocol132.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Protocol/Protocol132.cpp') diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 46ac4ef89..ab15509b7 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -5,7 +5,6 @@ #include "Globals.h" #include "ChunkDataSerializer.h" -#include "cryptopp/randpool.h" #include "Protocol132.h" #include "../Root.h" #include "../Server.h" @@ -19,8 +18,20 @@ #include "../WorldStorage/FastNBT.h" #include "../StringCompression.h" +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4127) + #pragma warning(disable:4244) + #pragma warning(disable:4231) + #pragma warning(disable:4189) + #pragma warning(disable:4702) +#endif +#include "cryptopp/randpool.h" +#ifdef _MSC_VER + #pragma warning(pop) +#endif #define HANDLE_PACKET_READ(Proc, Type, Var) \ -- cgit v1.2.3 From 9c8af58b7546448e9168ca6d70b5ba9a7f4330d7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 6 Jan 2014 22:22:33 +0100 Subject: Fixed a few MSVC warnings. --- src/Protocol/Protocol132.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Protocol/Protocol132.cpp') diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index ab15509b7..302d1298c 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -877,7 +877,7 @@ void cProtocol132::SendCompass(const cWorld & a_World) void cProtocol132::SendEncryptionKeyRequest(void) { cCSLock Lock(m_CSPacket); - WriteByte((char)0xfd); + WriteByte(0xfd); WriteString(cRoot::Get()->GetServer()->GetServerID()); WriteShort((short)m_ServerPublicKey.size()); SendData(m_ServerPublicKey.data(), m_ServerPublicKey.size()); @@ -925,7 +925,7 @@ void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const A { // Send encryption key response: cCSLock Lock(m_CSPacket); - WriteByte((char)0xfc); + WriteByte(0xfc); WriteShort(0); WriteShort(0); Flush(); -- cgit v1.2.3