mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 09:33:51 +00:00
fix(combatlog): fail classic and tbc spell go parse on truncation
This commit is contained in:
parent
e0ac81450d
commit
6b290009aa
2 changed files with 55 additions and 28 deletions
|
|
@ -397,6 +397,7 @@ bool ClassicPacketParsers::parseSpellStart(network::Packet& packet, SpellStartDa
|
|||
// ============================================================================
|
||||
bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& data) {
|
||||
auto rem = [&]() { return packet.getSize() - packet.getReadPos(); };
|
||||
const size_t startPos = packet.getReadPos();
|
||||
if (rem() < 2) return false;
|
||||
|
||||
if (!hasFullPackedGuid(packet)) return false;
|
||||
|
|
@ -418,23 +419,24 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
|
|||
}
|
||||
const uint8_t storedHitLimit = std::min<uint8_t>(rawHitCount, 128);
|
||||
data.hitTargets.reserve(storedHitLimit);
|
||||
uint16_t parsedHitCount = 0;
|
||||
bool truncatedTargets = false;
|
||||
for (uint16_t i = 0; i < rawHitCount; ++i) {
|
||||
if (!hasFullPackedGuid(packet)) {
|
||||
LOG_WARNING("[Classic] Spell go: truncated hit targets at index ", i,
|
||||
"/", (int)rawHitCount);
|
||||
truncatedTargets = true;
|
||||
break;
|
||||
}
|
||||
const uint64_t targetGuid = UpdateObjectParser::readPackedGuid(packet);
|
||||
++parsedHitCount;
|
||||
if (i < storedHitLimit) {
|
||||
data.hitTargets.push_back(targetGuid);
|
||||
}
|
||||
}
|
||||
data.hitCount = static_cast<uint8_t>(data.hitTargets.size());
|
||||
// Check if we read all expected hits
|
||||
if (parsedHitCount < rawHitCount) {
|
||||
LOG_WARNING("[Classic] Spell go: truncated hit targets at index ", (int)parsedHitCount,
|
||||
"/", (int)rawHitCount);
|
||||
if (truncatedTargets) {
|
||||
packet.setReadPos(startPos);
|
||||
return false;
|
||||
}
|
||||
data.hitCount = static_cast<uint8_t>(data.hitTargets.size());
|
||||
|
||||
// Miss targets
|
||||
if (rem() < 1) return true;
|
||||
|
|
@ -444,31 +446,41 @@ bool ClassicPacketParsers::parseSpellGo(network::Packet& packet, SpellGoData& da
|
|||
}
|
||||
const uint8_t storedMissLimit = std::min<uint8_t>(rawMissCount, 128);
|
||||
data.missTargets.reserve(storedMissLimit);
|
||||
uint16_t parsedMissCount = 0;
|
||||
for (uint16_t i = 0; i < rawMissCount; ++i) {
|
||||
if (!hasFullPackedGuid(packet)) {
|
||||
LOG_WARNING("[Classic] Spell go: truncated miss targets at index ", i,
|
||||
"/", (int)rawMissCount);
|
||||
truncatedTargets = true;
|
||||
break;
|
||||
}
|
||||
SpellGoMissEntry m;
|
||||
m.targetGuid = UpdateObjectParser::readPackedGuid(packet);
|
||||
if (rem() < 1) break;
|
||||
if (rem() < 1) {
|
||||
LOG_WARNING("[Classic] Spell go: missing missType at miss index ", i,
|
||||
"/", (int)rawMissCount);
|
||||
truncatedTargets = true;
|
||||
break;
|
||||
}
|
||||
m.missType = packet.readUInt8();
|
||||
if (m.missType == 11) {
|
||||
if (rem() < 5) break;
|
||||
if (rem() < 5) {
|
||||
LOG_WARNING("[Classic] Spell go: truncated reflect payload at miss index ", i,
|
||||
"/", (int)rawMissCount);
|
||||
truncatedTargets = true;
|
||||
break;
|
||||
}
|
||||
(void)packet.readUInt32();
|
||||
(void)packet.readUInt8();
|
||||
}
|
||||
++parsedMissCount;
|
||||
if (i < storedMissLimit) {
|
||||
data.missTargets.push_back(m);
|
||||
}
|
||||
}
|
||||
data.missCount = static_cast<uint8_t>(data.missTargets.size());
|
||||
// Check if we read all expected misses
|
||||
if (parsedMissCount < rawMissCount) {
|
||||
LOG_WARNING("[Classic] Spell go: truncated miss targets at index ", (int)parsedMissCount,
|
||||
"/", (int)rawMissCount);
|
||||
if (truncatedTargets) {
|
||||
packet.setReadPos(startPos);
|
||||
return false;
|
||||
}
|
||||
data.missCount = static_cast<uint8_t>(data.missTargets.size());
|
||||
|
||||
LOG_DEBUG("[Classic] Spell go: spell=", data.spellId, " hits=", (int)data.hitCount,
|
||||
" misses=", (int)data.missCount);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue