aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-07-30 10:39:53 +0800
committermegamage <none@none>2009-07-30 10:39:53 +0800
commitb2b3983e8976a5656e6d3cc79f5b04c9b773e881 (patch)
tree39e31476945a50b336d0b2126f81e9e207292cf8
parent5d9d64e6f048298a19f4c80795f05e31facb2318 (diff)
[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
-rw-r--r--src/game/MiscHandler.cpp5
-rw-r--r--src/game/Player.h2
-rw-r--r--src/game/UpdateData.cpp2
3 files changed, 5 insertions, 4 deletions
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<uint8*>(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 <class T> 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<uint32>(0, pSize);