fix: check a length read from a message against the data left in it

Several game messages read a 32 bit length and then read that many
characters without checking it, so the loop ran for the whole length
even after the message had ended. The length now has to fit in the
data the message has left. This covers the activity state, cinematic
path, death type, removed item info and inventory group messages and
the shared wide string reader.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 13:04:12 -06:00
parent 43cea3a245
commit 1ba8f26d2b
3 changed files with 48 additions and 1 deletions

View File

@@ -292,10 +292,12 @@ std::vector<std::string> GeneralUtils::SplitString(const std::string_view str, c
}
std::u16string GeneralUtils::ReadWString(RakNet::BitStream& inStream) {
uint32_t length;
uint32_t length = 0;
inStream.Read<uint32_t>(length);
std::u16string string;
if (!StreamHolds(inStream, length, sizeof(uint16_t))) return string;
for (uint32_t i = 0; i < length; ++i) {
uint16_t c;
inStream.Read(c);