From 397db256bc22ae8f6cbc360f175eb78509db9be2 Mon Sep 17 00:00:00 2001 From: Orycterope Date: Mon, 10 May 2021 09:26:40 +0200 Subject: [PATCH] Fix bitwise shift UB in filemap_fd on windows (#1489) Fixes #1302 --- libyara/filemap.c | 10 +++++----- libyara/include/yara/filemap.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libyara/filemap.c b/libyara/filemap.c index cebff1b9..b1a7a7d6 100644 --- a/libyara/filemap.c +++ b/libyara/filemap.c @@ -80,7 +80,7 @@ YR_API int yr_filemap_map(const char* file_path, YR_MAPPED_FILE* pmapped_file) YR_API int yr_filemap_map_fd( YR_FILE_DESCRIPTOR file, - off_t offset, + uint64_t offset, size_t size, YR_MAPPED_FILE* pmapped_file) { @@ -110,7 +110,7 @@ YR_API int yr_filemap_map_fd( return ERROR_COULD_NOT_OPEN_FILE; } - if (offset > (off_t) file_size) + if (offset > (uint64_t) file_size) return ERROR_COULD_NOT_MAP_FILE; if (size == 0) @@ -179,7 +179,7 @@ YR_API int yr_filemap_map_fd( YR_API int yr_filemap_map_fd( YR_FILE_DESCRIPTOR file, - off_t offset, + uint64_t offset, size_t size, YR_MAPPED_FILE* pmapped_file) { @@ -257,7 +257,7 @@ YR_API int yr_filemap_map_fd( YR_API int yr_filemap_map_ex( const char* file_path, - off_t offset, + uint64_t offset, size_t size, YR_MAPPED_FILE* pmapped_file) { @@ -291,7 +291,7 @@ YR_API int yr_filemap_map_ex( YR_API int yr_filemap_map_ex( const char* file_path, - off_t offset, + uint64_t offset, size_t size, YR_MAPPED_FILE* pmapped_file) { diff --git a/libyara/include/yara/filemap.h b/libyara/include/yara/filemap.h index eb458d25..81060147 100644 --- a/libyara/include/yara/filemap.h +++ b/libyara/include/yara/filemap.h @@ -61,14 +61,14 @@ YR_API int yr_filemap_map(const char* file_path, YR_MAPPED_FILE* pmapped_file); YR_API int yr_filemap_map_fd( YR_FILE_DESCRIPTOR file, - off_t offset, + uint64_t offset, size_t size, YR_MAPPED_FILE* pmapped_file); YR_API int yr_filemap_map_ex( const char* file_path, - off_t offset, + uint64_t offset, size_t size, YR_MAPPED_FILE* pmapped_file);