Skip to content

Commit

Permalink
Fix buffer overflow in MD5Parser::SkipSpacesAndLineEnd (assimp#5921)
Browse files Browse the repository at this point in the history
Co-authored-by: Kim Kulling <[email protected]>
  • Loading branch information
tyler92 and kimkulling authored Dec 17, 2024
1 parent 2090508 commit ecc8a1c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions code/AssetLib/MD5/MD5Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,18 @@ void MD5Parser::ParseHeader() {
ReportError("MD5 version tag is unknown (10 is expected)");
}
SkipLine();
if (buffer == bufferEnd) {
return;
}

// print the command line options to the console
// FIX: can break the log length limit, so we need to be careful
char *sz = buffer;
while (!IsLineEnd(*buffer++));
while (buffer < bufferEnd) {
if (IsLineEnd(*buffer++)) {
break;
}
}

if (buffer == bufferEnd) {
return;
}

ASSIMP_LOG_INFO(std::string(sz, std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer - sz))));
SkipSpacesAndLineEnd();
Expand Down

0 comments on commit ecc8a1c

Please sign in to comment.