aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-08-05 14:13:17 +0200
committerShauren <shauren.trinity@gmail.com>2024-08-05 14:13:17 +0200
commita4ecb2dfae8bb4a1eeccf9f97af5948078266a5c (patch)
treee635a1b629ebc0237e44b175d73742bc3dac3ca0
parentdabe1f85df30610c5287ae6d8214d325e6595387 (diff)
Core/PacketIO: Fixed handling CMSG_UPDATE_ACCOUNT_DATA - compressed value is not a null-terminated string
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp10
-rw-r--r--src/server/shared/Packets/ByteBuffer.h7
2 files changed, 6 insertions, 11 deletions
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 3cf1d49221a..0ed51e367ce 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -706,19 +706,17 @@ void WorldSession::HandleUpdateAccountData(WorldPackets::ClientConfig::UserClien
return;
}
- ByteBuffer dest(packet.Size, ByteBuffer::Resize{});
+ std::string dest;
+ dest.resize(packet.Size);
uLongf realSize = packet.Size;
- if (uncompress(dest.contents(), &realSize, packet.CompressedData.contents(), packet.CompressedData.size()) != Z_OK)
+ if (uncompress(reinterpret_cast<Bytef*>(dest.data()), &realSize, packet.CompressedData.contents(), packet.CompressedData.size()) != Z_OK)
{
TC_LOG_ERROR("network", "UAD: Failed to decompress account data");
return;
}
- std::string adata;
- dest >> adata;
-
- SetAccountData(AccountDataType(packet.DataType), packet.Time, adata);
+ SetAccountData(AccountDataType(packet.DataType), packet.Time, dest);
}
void WorldSession::HandleRequestAccountData(WorldPackets::ClientConfig::RequestAccountData& request)
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index 9233c4f5150..e7fa67d632f 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -633,16 +633,13 @@ class TC_SHARED_API ByteBuffer
/// @todo Make a ByteBuffer.cpp and move all this inlining to it.
template<> inline std::string ByteBuffer::read<std::string>()
{
- std::string tmp;
- *this >> tmp;
- return tmp;
+ return std::string(ReadCString());
}
template<>
inline void ByteBuffer::read_skip<char*>()
{
- std::string temp;
- *this >> temp;
+ (void)ReadCString();
}
template<>