user gszy comment
Comment was:
removing the MAX_FILE_SIZE ifdef/define/endif,
replacing the st.st_size > (off_t)SSIZE_MAX test with st.st_size > (intmax_t) SIZE_MAX,
perhaps removing the sizeof(st.st_size) != sizeof(size_t) test as well.
done here
#define O_BINARY 0
#endif
-#ifndef MAX_FILE_SIZE
-#define MAX_FILE_SIZE (1<<20) // signed long int max value
-#endif
-
#ifdef _MSC_VER
#define __attribute__(x)
#endif
@@ -2202,14 +2198,11 @@ static int map_file(mapped_file_t *mf, const char *path) {
goto on_error;
}
- if (sizeof(st.st_size) != sizeof(size_t)) {
- // on 32 bit systems, check if there is an overflow
- if (st.st_size > (off_t)MAX_FILE_SIZE /*1 GB*/ ) {
- // limit file size to 1 GB
+ if (st.st_size > (intmax_t) SIZE_MAX ) {
fprintf(stderr, "mmap() file %s too big\n", path);
goto on_error;
}
- }
+
mf->base =
(uint8_t *)mmap(NULL, (size_t)(st.st_size), PROT_READ, MAP_SHARED, fd, 0);
