From 002c2b6170b3fd2aa704dd72c6601fe4201b31f6 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 1 Apr 2022 10:23:29 -0700 Subject: [PATCH] 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. --- src/history_file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/history_file.cpp b/src/history_file.cpp index 711e66825..dd2ce7389 100644 --- a/src/history_file.cpp +++ b/src/history_file.cpp @@ -157,7 +157,7 @@ bool history_file_contents_t::infer_file_type() { std::unique_ptr 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(len) >= SIZE_MAX) return nullptr; + if (len <= 0 || static_cast(len) >= static_cast(SIZE_MAX)) return nullptr; bool mmap_file_directly = should_mmap(); std::unique_ptr region =