fix range checking of file-position values

svn: r7316
This commit is contained in:
Matthew Flatt 2007-09-11 15:14:13 +00:00
parent 19c5c227c9
commit ef7223ab49
2 changed files with 14 additions and 0 deletions

View File

@ -246,6 +246,7 @@ typedef struct Scheme_FD {
# define ftello _ftelli64
#endif
/******************** Globals and Prototypes ********************/
/* globals */
@ -4141,7 +4142,14 @@ scheme_file_position(int argc, Scheme_Object *argv[])
whence = SEEK_END;
} else if (scheme_get_long_long_val(argv[1], &nll)) {
whence = SEEK_SET;
if ((mzlonglong)(mz_off_t)nll != nll) {
nll = -1;
}
} else {
nll = -1;
}
if (nll < 0) {
scheme_raise_exn(MZEXN_FAIL_CONTRACT,
"file-position: new position is too large: %s for port: %s",
scheme_make_provided_string(argv[1], 2, NULL),

View File

@ -2567,8 +2567,14 @@ Scheme_Object *scheme_get_native_arity(Scheme_Object *closure);
#ifdef USE_TRANSITIONAL_64_FILE_OPS
# define BIG_OFF_T_IZE(n) n ## 64
# define mz_off_t off64_t
#else
# define BIG_OFF_T_IZE(n) n
# if defined(DOS_FILE_SYSTEM)
# define mz_off_t mzlonglong
# else
# define mz_off_t off_t
# endif
#endif
int scheme_is_relative_path(const char *s, long len, int kind);