Correct a cast when measuring history file size

If the history file is larger than 4GB on a 32 bit system, fish will
refuse to read it. However the check was incorrect because it cast the
file size to size_t, which may be 32 bit. Switch to using uint64.
This commit is contained in:
ridiculousfish 2022-04-01 10:23:29 -07:00
parent a91e1a8cab
commit 002c2b6170

View file

@ -157,7 +157,7 @@ bool history_file_contents_t::infer_file_type() {
std::unique_ptr<history_file_contents_t> history_file_contents_t::create(int fd) {
// Check that the file is seekable, and its size.
off_t len = lseek(fd, 0, SEEK_END);
if (len <= 0 || static_cast<unsigned long>(len) >= SIZE_MAX) return nullptr;
if (len <= 0 || static_cast<uint64_t>(len) >= static_cast<uint64_t>(SIZE_MAX)) return nullptr;
bool mmap_file_directly = should_mmap();
std::unique_ptr<mmap_region_t> region =