Subject: Try to use the "right" off_t_max Origin: FILE5_34-13-gcd752e7c Upstream-Author: Christos Zoulas Date: Wed Aug 1 09:53:18 2018 +0000 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -55,11 +55,6 @@ #include #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;