lib/nbt: fix a bug in NBT::helper::readString() which caused it to asuume that dataSize is the size of the string
parent
9190cad80d
commit
884a5239c6
|
@ -146,11 +146,16 @@ namespace NBT {
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<tiny_utf8::string> readString(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<tiny_utf8::string> readString(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
if(dataSize > 0xFFFF){
|
if(currentPosition > dataSize){
|
||||||
return ErrorOr<tiny_utf8::string>(true, ErrorCodes::OVERRUN);
|
return ErrorOr<tiny_utf8::string>(true, ErrorCodes::OVERRUN);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<tiny_utf8::string> output = JavaCompat::importJavaString(data+currentPosition, (uint16_t) dataSize);
|
ErrorOr<int16_t> stringSize = readInt16(data, dataSize, currentPosition);
|
||||||
|
if (stringSize.isError) {
|
||||||
|
return ErrorOr<tiny_utf8::string>(true, stringSize.errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<tiny_utf8::string> output = JavaCompat::importJavaString(data+currentPosition, stringSize.value);
|
||||||
if(output.isError){
|
if(output.isError){
|
||||||
return ErrorOr<tiny_utf8::string>(true, output.errorCode);
|
return ErrorOr<tiny_utf8::string>(true, output.errorCode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue