mruby-io/io.c: raise error if seek position is too big

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-12-28 10:43:35 +09:00
parent f3a5f3ee1d
commit 8e1a82b424
+3 -8
View File
@@ -987,15 +987,10 @@ mrb_io_sysseek(mrb_state *mrb, mrb_value io)
if (pos == -1) {
mrb_sys_fail(mrb, "sysseek");
}
if (pos > MRB_INT_MAX) {
#ifndef MRB_NO_FLOAT
return mrb_float_value(mrb, (mrb_float)pos);
#else
mrb_raise(mrb, E_IO_ERROR, "sysseek reached too far for MRB_NO_FLOAT");
#endif
} else {
return mrb_int_value(mrb, pos);
if (pos > (off_t)MRB_INT_MAX) {
mrb_raise(mrb, E_IO_ERROR, "sysseek reached too far for mrb_int");
}
return mrb_int_value(mrb, (mrb_int)pos);
}
static mrb_value