From a91e1a8cab562fdac525deb339e73ba525338f39 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 1 Apr 2022 10:18:06 -0700 Subject: [PATCH] Revert "history_file_contents_t::create: remove constant comparison" This reverts commit d7b41939788162aa9a5459d9c77009d09ec56718. off_t may be wider than size_t on a 32 bit system so the comparison is justified (though the cast is not). --- 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 beb849a05..711e66825 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) return nullptr; + if (len <= 0 || static_cast(len) >= SIZE_MAX) return nullptr; bool mmap_file_directly = should_mmap(); std::unique_ptr region =