This is an automated email from the ASF dual-hosted git repository. colinlee pushed a commit to branch colin_fix_read_overflow in repository https://gitbox.apache.org/repos/asf/tsfile.git
commit 69ac3b8c17d583ba55d24197e8cc9b2fd583c70a Author: ColinLee <[email protected]> AuthorDate: Thu May 15 17:37:10 2025 +0800 fix file size overflow. --- cpp/src/file/read_file.cc | 4 ++-- cpp/src/file/read_file.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp/src/file/read_file.cc b/cpp/src/file/read_file.cc index cc08bf25..c47268d6 100644 --- a/cpp/src/file/read_file.cc +++ b/cpp/src/file/read_file.cc @@ -65,7 +65,7 @@ int ReadFile::open(const std::string &file_path) { return ret; } -int ReadFile::get_file_size(int32_t &file_size) { +int64_t ReadFile::get_file_size(int64_t &file_size) { struct stat s; if (fstat(fd_, &s) < 0) { LOGE("fstat error, file_path=" << file_path_.c_str() << "fd=" << fd_ @@ -109,7 +109,7 @@ int ReadFile::check_file_magic() { return ret; } -int ReadFile::read(int32_t offset, char *buf, int32_t buf_size, +int ReadFile::read(int64_t offset, char *buf, int32_t buf_size, int32_t &read_len) { int ret = E_OK; read_len = 0; diff --git a/cpp/src/file/read_file.h b/cpp/src/file/read_file.h index a0648284..f0e61edd 100644 --- a/cpp/src/file/read_file.h +++ b/cpp/src/file/read_file.h @@ -37,19 +37,19 @@ class ReadFile { int open(const std::string &file_path); FORCE_INLINE bool is_opened() const { return fd_ > 0; } - FORCE_INLINE int32_t file_size() const { return file_size_; } + FORCE_INLINE int64_t file_size() const { return file_size_; } FORCE_INLINE const std::string &file_path() const { return file_path_; } /* * try to reader @buf_size bytes from @offset of this file * into @buf. @read_len return the actual len reader. */ - int read(int32_t offset, char *buf, int32_t buf_size, + int read(int64_t offset, char *buf, int32_t buf_size, int32_t &ret_read_len); void close(); private: - int get_file_size(int32_t &file_size); + int64_t get_file_size(int64_t &file_size); int check_file_magic(); private: @@ -59,7 +59,7 @@ class ReadFile { private: std::string file_path_; int fd_; - int32_t file_size_; + int64_t file_size_; }; } // end namespace storage
