diff --git a/src/lib/nbt.cpp b/src/lib/nbt.cpp index 91d2b3b..6a8a329 100644 --- a/src/lib/nbt.cpp +++ b/src/lib/nbt.cpp @@ -146,11 +146,16 @@ namespace NBT { } ErrorOr readString(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) { - if(dataSize > 0xFFFF){ + if(currentPosition > dataSize){ return ErrorOr(true, ErrorCodes::OVERRUN); } - ErrorOr output = JavaCompat::importJavaString(data+currentPosition, (uint16_t) dataSize); + ErrorOr stringSize = readInt16(data, dataSize, currentPosition); + if (stringSize.isError) { + return ErrorOr(true, stringSize.errorCode); + } + + ErrorOr output = JavaCompat::importJavaString(data+currentPosition, stringSize.value); if(output.isError){ return ErrorOr(true, output.errorCode); }