From: Joel Rosdahl Date: Sat, 10 Feb 2024 20:33:08 +0000 (+0100) Subject: chore: Bail out on too large files on 32-bit systems X-Git-Tag: v4.10~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4f50ac7c160119ae363c934ef84adad69a68ecf;p=thirdparty%2Fccache.git chore: Bail out on too large files on 32-bit systems --- diff --git a/src/util/file.cpp b/src/util/file.cpp index 5b776297..87600422 100644 --- a/src/util/file.cpp +++ b/src/util/file.cpp @@ -240,6 +240,12 @@ read_file(const fs::path& path, size_t size_hint) size_hint = de.size(); } + if (size_hint > std::numeric_limits::max() / 4) { + // Too large value on a 32-bit system won't work well, better bail. + return tl::unexpected( + FMT("too large file: {} ({} bytes)", path, size_hint)); + } + const int open_flags = [] { if constexpr (std::is_same::value) { return O_RDONLY | O_TEXT;