diff options
Diffstat (limited to '')
-rw-r--r-- | minzip/SysUtil.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/minzip/SysUtil.c b/minzip/SysUtil.c index e7dd17b51..de47edfd9 100644 --- a/minzip/SysUtil.c +++ b/minzip/SysUtil.c @@ -8,6 +8,7 @@ #include <fcntl.h> #include <limits.h> #include <stdbool.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -118,13 +119,13 @@ static int sysMapBlockFile(FILE* mapf, MemMapping* pMap) break; } size_t length = (end - start) * blksize; - if (end <= start || (end - start) > SIZE_MAX / blksize || length > remaining_size) { - LOGE("unexpected range in block map: %zu %zu\n", start, end); - success = false; - break; + if (end <= start || ((end - start) > SIZE_MAX / blksize) || length > remaining_size) { + LOGE("unexpected range in block map: %zu %zu\n", start, end); + success = false; + break; } - void* addr = mmap64(next, length, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, ((off64_t)start)*blksize); + void* addr = mmap64(next, length, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, ((off64_t)(start*blksize))); if (addr == MAP_FAILED) { LOGE("failed to map block %d: %s\n", i, strerror(errno)); success = false; @@ -137,14 +138,14 @@ static int sysMapBlockFile(FILE* mapf, MemMapping* pMap) remaining_size -= length; } if (success && remaining_size != 0) { - LOGE("ranges in block map are invalid: remaining_size = %zu\n", remaining_size); - success = false; + LOGE("ranges in block map are invalid: remaining_size = %zu\n", remaining_size); + success = false; } if (!success) { - close(fd); - munmap(reserve, blocks * blksize); - free(pMap->ranges); - return -1; + close(fd); + munmap(reserve, blocks * blksize); + free(pMap->ranges); + return -1; } close(fd); |