Fix classic Warden check parsing for module and MPQ payload sizes

This commit is contained in:
Kelsi 2026-02-20 01:27:09 -08:00
parent d8ab69f9c3
commit b1d2da9507

View file

@ -3469,9 +3469,21 @@ void GameHandler::handleWardenData(network::Packet& packet) {
break; break;
} }
case CT_MPQ: { case CT_MPQ: {
// Request: [1 stringIdx] // Request layout differs across client generations.
if (pos + 1 > checkEnd) { pos = checkEnd; break; } // Classic commonly carries an extended MPQ check payload.
uint8_t strIdx = decrypted[pos++]; int mpqReqSize = (build <= 6005) ? 29 : 1;
if (pos + mpqReqSize > checkEnd) {
size_t remaining = checkEnd - pos;
LOG_WARNING("Warden: MPQ check truncated (remaining=", remaining,
", expected=", mpqReqSize, "), consuming remainder");
pos = checkEnd;
// Still return a placeholder result byte+hash to keep response framing stable.
resultData.push_back(0x00);
for (int i = 0; i < 20; i++) resultData.push_back(0x00);
break;
}
uint8_t strIdx = decrypted[pos];
pos += mpqReqSize;
LOG_INFO("Warden: MPQ file=\"", LOG_INFO("Warden: MPQ file=\"",
(strIdx < strings.size() ? strings[strIdx] : "?"), "\""); (strIdx < strings.size() ? strings[strIdx] : "?"), "\"");
// Response: [uint8 result=0][20 sha1 zeros] // Response: [uint8 result=0][20 sha1 zeros]
@ -3503,9 +3515,17 @@ void GameHandler::handleWardenData(network::Packet& packet) {
break; break;
} }
case CT_MODULE: { case CT_MODULE: {
// Request: [4 seed][20 sha1] // Module check request size differs by client generation.
if (pos + 24 > checkEnd) { pos = checkEnd; break; } // Classic packets can carry a shorter payload here.
pos += 24; int moduleSize = (build <= 6005) ? 16 : 24;
if (pos + moduleSize > checkEnd) {
size_t remaining = checkEnd - pos;
LOG_WARNING("Warden: MODULE check truncated (remaining=", remaining,
", expected=", moduleSize, "), consuming remainder");
pos = checkEnd;
} else {
pos += moduleSize;
}
// Response: [uint8 result=1] (module NOT loaded = clean) // Response: [uint8 result=1] (module NOT loaded = clean)
resultData.push_back(0x01); resultData.push_back(0x01);
break; break;