lib/nbt: Validator: Fix bytes not being added up correctly in multiple places
parent
589cf1ddaf
commit
25bec4c587
|
@ -585,7 +585,7 @@ namespace NBT {
|
||||||
// type byte + two name size bytes = 3
|
// type byte + two name size bytes = 3
|
||||||
uint8_t contentType = data[initialPosition + nameSize + 3];
|
uint8_t contentType = data[initialPosition + nameSize + 3];
|
||||||
// type byte + two name size bytes + contained type byte + 4 length bytes = 8
|
// type byte + two name size bytes + contained type byte + 4 length bytes = 8
|
||||||
*processedDataSize = 8;
|
*processedDataSize = (uint64_t) nameSize + 8;
|
||||||
switch (contentType) {
|
switch (contentType) {
|
||||||
case TagType::END:
|
case TagType::END:
|
||||||
// everything except content has been touched at this point
|
// everything except content has been touched at this point
|
||||||
|
@ -738,11 +738,12 @@ namespace NBT {
|
||||||
// checked while trying to parse the string above
|
// checked while trying to parse the string above
|
||||||
int16_t nameSize = helper::readInt16(data, dataSize, currentPosition+1).value;
|
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;
|
delete processedTagSize;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*processedTagSize += (uint64_t) nameSize + 1;
|
*processedTagSize += (uint64_t) nameSize + 3;
|
||||||
}
|
}
|
||||||
currentPosition += *processedTagSize;
|
currentPosition += *processedTagSize;
|
||||||
|
|
||||||
|
@ -758,6 +759,7 @@ namespace NBT {
|
||||||
|
|
||||||
// recursion abort condition
|
// recursion abort condition
|
||||||
if (data[currentPosition]==TagType::END) {
|
if (data[currentPosition]==TagType::END) {
|
||||||
|
currentPosition++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue