Compare commits

..

No commits in common. "5272636cb8fa394e1cc959d0f24b0580a732c37d" and "ca7b121c4dcb9bb2a048aea6c27dcf1988ee7ade" have entirely different histories.

3 changed files with 4 additions and 17 deletions

View File

@ -154,9 +154,6 @@ namespace NBT {
if (stringSize.isError) { if (stringSize.isError) {
return ErrorOr<tiny_utf8::string>(true, stringSize.errorCode); return ErrorOr<tiny_utf8::string>(true, stringSize.errorCode);
} }
if (currentPosition + (uint64_t) stringSize.value + 2 > dataSize) {
return ErrorOr<tiny_utf8::string>(true, ErrorCodes::OVERRUN);
}
ErrorOr<tiny_utf8::string> output = JavaCompat::importJavaString(data+currentPosition, stringSize.value); ErrorOr<tiny_utf8::string> output = JavaCompat::importJavaString(data+currentPosition, stringSize.value);
if(output.isError){ if(output.isError){

View File

@ -75,16 +75,7 @@ int main(){
tiny_utf8::string normalString = tiny_utf8::string(normalStdString); tiny_utf8::string normalString = tiny_utf8::string(normalStdString);
// check for normal operation
ASSERT(normalString == importedString); ASSERT(normalString == importedString);
// check for mismatched size error
std::string javaStdStringCopy = javaStdString;
javaStdStringCopy[0]='b';
ErrorOr<tiny_utf8::string> errorString = JavaCompat::importJavaString(reinterpret_cast<uint8_t*>(javaStdStringCopy.data()), 0x75);
ASSERT(errorString.isError);
ASSERT(errorString.errorCode == ErrorCodes::MISMATCHEDSIZE);
std::cout << "Passed Import Java string test." << std::endl; std::cout << "Passed Import Java string test." << std::endl;
//using normalString from when we read the file earlier //using normalString from when we read the file earlier
@ -100,5 +91,5 @@ int main(){
std::cout << "Passed Export Java string test." << std::endl; std::cout << "Passed Export Java string test." << std::endl;
delete nextChar; delete nextChar;
return 0; return 0;
} }

View File

@ -490,10 +490,9 @@ int main(){
tiny_utf8::string normalString = tiny_utf8::string(normalStdString); tiny_utf8::string normalString = tiny_utf8::string(normalStdString);
ASSERT(normalString == NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), 0).value) ASSERT(normalString == NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), 0x75, 0).value)
ASSERT(NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), 0xFFFFF, 0).errorCode == ErrorCodes::OVERRUN);
javaStdString[0] = '1'; ASSERT(NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), 0xF, 0).errorCode == ErrorCodes::MISMATCHEDSIZE);
ASSERT(NBT::helper::readString(reinterpret_cast<uint8_t*>(javaStdString.data()), javaStdString.size(), 0).errorCode == ErrorCodes::OVERRUN);
std::cout << "Passed readString NBT helper test." << std::endl; std::cout << "Passed readString NBT helper test." << std::endl;
delete nextChar; delete nextChar;