Fix #11644: Off by one error/buffer over-read in StrMakeValid (#11645)

* Fix #11644: Off by one error in StrMakeValid UTF-8 decode overrun detection

* Fix #11644: Off by one error in StrMakeValid buffer last character

* Fix: Unnecessary string duplication at StrMakeValid call sites
This commit is contained in:
Jonathan G Rennison
2024-01-01 18:26:31 +00:00
committed by GitHub
parent a672813bb0
commit 88324a253e
3 changed files with 6 additions and 4 deletions

View File

@@ -486,7 +486,7 @@ static std::string ExtractString(char *buffer, size_t buffer_length)
{
size_t length = 0;
for (; length < buffer_length && buffer[length] != '\0'; length++) {}
return StrMakeValid(std::string(buffer, length));
return StrMakeValid(std::string_view(buffer, length));
}
bool TarScanner::AddFile(const std::string &filename, size_t, [[maybe_unused]] const std::string &tar_filename)