diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-08-16 02:52:25 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-08-16 02:52:25 +0000 |
commit | 2229b70615ce502c567d6c27357ac2ccfa70eefd (patch) | |
tree | 6036f34b37a752dbc9708aa110a936a13484b5a7 /marshal.c | |
parent | 3d923fb9285b4bae77925d362118a463e00867e4 (diff) | |
download | ruby-2229b70615ce502c567d6c27357ac2ccfa70eefd.tar.gz |
* io.c (rb_io_fread): renamed from io_fread and made extern.
* marshal.c (r_bytes0): check if successfully read, use
rb_io_fread() instead of fread() to be preemptive.
(ruby-bugs-ja:PR#294, 295)
* rubyio.h (rb_io_fread): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r-- | marshal.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -712,11 +712,14 @@ r_bytes0(s, len, arg) struct load_arg *arg; { if (arg->fp) { - len = fread(s, 1, len, arg->fp); + if (rb_io_fread(s, len, arg->fp) != len) { + too_short: + rb_raise(rb_eArgError, "marshal data too short"); + } } else { if (arg->ptr + len > arg->end) { - len = arg->end - arg->ptr; + goto too_short; } memcpy(s, arg->ptr, len); arg->ptr += len; |