This commit is contained in:
Loïc Guilloux 2024-04-27 21:14:06 +00:00 committed by GitHub
commit 090cb2184c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include <unistd.h>
#include <pwd.h>
#endif
#include <charconv>
#include <sys/stat.h>
#include <sstream>
#include <filesystem>
@ -563,7 +564,16 @@ bool TarScanner::AddFile(const std::string &filename, size_t, [[maybe_unused]] c
/* The size of the file, for some strange reason, this is stored as a string in octals. */
std::string size = ExtractString(th.size);
size_t skip = size.empty() ? 0 : std::stoul(size, nullptr, 8);
size_t skip = 0;
if (!size.empty()) {
StrTrimInPlace(size);
auto [_, err] = std::from_chars(size.data(), size.data() + size.size(), skip, 8);
if (err != std::errc()) {
Debug(misc, 0, "The file '{}' has an invalid size for '{}'", filename, name);
fclose(f);
return false;
}
}
switch (th.typeflag) {
case '\0':