From b2b3983e8976a5656e6d3cc79f5b04c9b773e881 Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 30 Jul 2009 10:39:53 +0800 Subject: [8231] Use more safe destination buffer size for zlib compression. Author: SilverIce [8230] Add new line at the end of file Player.h to make gcc happy. Author: Gendalph --HG-- branch : trunk --- src/game/MiscHandler.cpp | 5 +++-- src/game/Player.h | 2 +- src/game/UpdateData.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 2488e7696e0..c2a93c36e0c 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -1018,10 +1018,11 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) uint32 size = adata->Data.size(); + uLongf destSize = compressBound(size); + ByteBuffer dest; - dest.resize(size); + dest.resize(destSize); - uLongf destSize = size; if(size && compress(const_cast(dest.contents()), &destSize, (uint8*)adata->Data.c_str(), size) != Z_OK) { sLog.outDebug("RAD: Failed to compress account data"); diff --git a/src/game/Player.h b/src/game/Player.h index 85faad96407..49d4c1346b9 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2462,4 +2462,4 @@ template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &bas basevalue = T((float)basevalue + diff); return T(diff); } -#endif \ No newline at end of file +#endif diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp index a3192b74b0e..e461d63e248 100644 --- a/src/game/UpdateData.cpp +++ b/src/game/UpdateData.cpp @@ -128,7 +128,7 @@ bool UpdateData::BuildPacket(WorldPacket *packet) if (pSize > 100 ) // compress large packets { - uint32 destsize = pSize; + uint32 destsize = compressBound(pSize); packet->resize( destsize + sizeof(uint32) ); packet->put(0, pSize); -- cgit v1.2.3