summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-16 02:52:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-16 02:52:25 +0000
commit2229b70615ce502c567d6c27357ac2ccfa70eefd (patch)
tree6036f34b37a752dbc9708aa110a936a13484b5a7 /marshal.c
parent3d923fb9285b4bae77925d362118a463e00867e4 (diff)
* 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.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/marshal.c b/marshal.c
index 9bed4296fc..94a2eb56da 100644
--- a/marshal.c
+++ b/marshal.c
@@ -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;