summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Authenticator.cpp33
-rw-r--r--src/Protocol/Protocol125.cpp2
-rw-r--r--src/Protocol/Protocol17x.cpp10
3 files changed, 41 insertions, 4 deletions
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index e0fcc0007..bbc656eda 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -165,6 +165,10 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
if ((ret = ctr_drbg_init(&ctr_drbg, entropy_func, &entropy, (const unsigned char *)pers, strlen(pers))) != 0)
{
LOGWARNING("cAuthenticator: ctr_drbg_init returned %d", ret);
+
+ // Free all resources which have been initialized up to this line
+ x509_crt_free(&cacert);
+ entropy_free(&entropy);
return false;
}
@@ -175,6 +179,10 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
if (ret < 0)
{
LOGWARNING("cAuthenticator: x509_crt_parse returned -0x%x", -ret);
+
+ // Free all resources which have been initialized up to this line
+ x509_crt_free(&cacert);
+ entropy_free(&entropy);
return false;
}
@@ -182,6 +190,10 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
if ((ret = net_connect(&server_fd, m_Server.c_str(), 443)) != 0)
{
LOGWARNING("cAuthenticator: Can't connect to %s: %d", m_Server.c_str(), ret);
+
+ // Free all resources which have been initialized up to this line
+ x509_crt_free(&cacert);
+ entropy_free(&entropy);
return false;
}
@@ -189,6 +201,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
if ((ret = ssl_init(&ssl)) != 0)
{
LOGWARNING("cAuthenticator: ssl_init returned %d", ret);
+
+ // Free all resources which have been initialized up to this line
+ x509_crt_free(&cacert);
+ net_close(server_fd);
+ ssl_free(&ssl);
+ entropy_free(&entropy);
+ memset(&ssl, 0, sizeof(ssl));
return false;
}
ssl_set_endpoint(&ssl, SSL_IS_CLIENT);
@@ -203,6 +222,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
if ((ret != POLARSSL_ERR_NET_WANT_READ) && (ret != POLARSSL_ERR_NET_WANT_WRITE))
{
LOGWARNING("cAuthenticator: ssl_handshake returned -0x%x", -ret);
+
+ // Free all resources which have been initialized up to this line
+ x509_crt_free(&cacert);
+ net_close(server_fd);
+ ssl_free(&ssl);
+ entropy_free(&entropy);
+ memset(&ssl, 0, sizeof(ssl));
return false;
}
}
@@ -223,6 +249,13 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
if (ret <= 0)
{
LOGWARNING("cAuthenticator: ssl_write returned %d", ret);
+
+ // Free all resources which have been initialized up to this line
+ x509_crt_free(&cacert);
+ net_close(server_fd);
+ ssl_free(&ssl);
+ entropy_free(&entropy);
+ memset(&ssl, 0, sizeof(ssl));
return false;
}
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index a23afb29a..35ab72bfc 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -26,7 +26,7 @@ Documentation:
#include "../Root.h"
#include "../Server.h"
-#include "../Entities/ProjectileEntity.h"
+#include "../Entities/ArrowEntity.h"
#include "../Entities/Minecart.h"
#include "../Entities/FallingBlock.h"
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 80b161e3e..a04d8ac3c 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -31,6 +31,8 @@ Implements the 1.7.x protocol classes:
#include "../BlockEntities/MobHeadEntity.h"
#include "../BlockEntities/FlowerPotEntity.h"
#include "../CompositeChat.h"
+#include "../Entities/ArrowEntity.h"
+#include "../Entities/FireworkEntity.h"
@@ -637,9 +639,11 @@ void cProtocol172::SendLoginSuccess(void)
{
ASSERT(m_State == 2); // State: login?
- cPacketizer Pkt(*this, 0x02); // Login success packet
- Pkt.WriteString(m_Client->GetUUID());
- Pkt.WriteString(m_Client->GetUsername());
+ {
+ cPacketizer Pkt(*this, 0x02); // Login success packet
+ Pkt.WriteString(m_Client->GetUUID());
+ Pkt.WriteString(m_Client->GetUsername());
+ }
m_State = 3; // State = Game
}