lib/nbt: Validator: Fix bytes not being added up correctly in multiple places

Soda
BodgeMaster 2022-08-15 10:51:50 +02:00
parent 589cf1ddaf
commit 25bec4c587
1 changed files with 5 additions and 3 deletions

View File

@ -585,7 +585,7 @@ namespace NBT {
// type byte + two name size bytes = 3
uint8_t contentType = data[initialPosition + nameSize + 3];
// type byte + two name size bytes + contained type byte + 4 length bytes = 8
*processedDataSize = 8;
*processedDataSize = (uint64_t) nameSize + 8;
switch (contentType) {
case TagType::END:
// everything except content has been touched at this point
@ -738,11 +738,12 @@ namespace NBT {
// checked while trying to parse the string above
int16_t nameSize = helper::readInt16(data, dataSize, currentPosition+1).value;
if (!validateRawNBTData(data, dataSize, currentPosition + (uint64_t) nameSize + 1, processedTagSize)) {
// type byte + two name size bytes = 3
if (!validateRawNBTData(data, dataSize, currentPosition + (uint64_t) nameSize + 3, processedTagSize)) {
delete processedTagSize;
return false;
}
*processedTagSize += (uint64_t) nameSize + 1;
*processedTagSize += (uint64_t) nameSize + 3;
}
currentPosition += *processedTagSize;
@ -758,6 +759,7 @@ namespace NBT {
// recursion abort condition
if (data[currentPosition]==TagType::END) {
currentPosition++;
return true;
}