1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- Subject: Try to use the "right" off_t_max
- Origin: FILE5_34-13-gcd752e7c <https://github.com/file/file/commit/FILE5_34-13-gcd752e7c>
- Upstream-Author: Christos Zoulas <christos@zoulas.com>
- Date: Wed Aug 1 09:53:18 2018 +0000
- --- a/src/apprentice.c
- +++ b/src/apprentice.c
- @@ -55,11 +55,6 @@
- #include <limits.h>
- #endif
-
- -#ifndef SSIZE_MAX
- -#define MAXMAGIC_SIZE ((ssize_t)0x7fffffff)
- -#else
- -#define MAXMAGIC_SIZE SSIZE_MAX
- -#endif
-
- #define EATAB {while (isascii((unsigned char) *l) && \
- isspace((unsigned char) *l)) ++l;}
- @@ -300,6 +295,15 @@
- return p->type;
- }
-
- +private off_t
- +maxoff_t(void) {
- + if (sizeof(off_t) == sizeof(int))
- + return CAST(off_t, INT_MAX);
- + if (sizeof(off_t) == sizeof(long))
- + return CAST(off_t, LONG_MAX);
- + return 0x7fffffff;
- +}
- +
- private int
- get_standard_integer_type(const char *l, const char **t)
- {
- @@ -2950,7 +2954,7 @@
- file_error(ms, errno, "cannot stat `%s'", dbname);
- goto error;
- }
- - if (st.st_size < 8 || st.st_size > MAXMAGIC_SIZE) {
- + if (st.st_size < 8 || st.st_size > maxoff_t()) {
- file_error(ms, 0, "file `%s' is too %s", dbname,
- st.st_size < 8 ? "small" : "large");
- goto error;
|