diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-12-14 06:50:43 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-12-14 06:50:43 +0000 |
commit | 9d228b13deccfdf23f44e2c465f723a2a7b3bcbd (patch) | |
tree | 9a4d769804c389b6b03bbfdf65e8e0a03288c8e8 /io.c | |
parent | c18d3740a925e8752c3b93acea6087fb0e03be53 (diff) |
19991214
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -969,7 +969,9 @@ static VALUE rb_io_close_method(io) VALUE io; { - rb_secure(4); + if (rb_safe_level() >= 4 && !OBJ_TAINTED(io)) { + rb_raise(rb_eSecurityError, "Insecure: can't close"); + } rb_io_close(io); return Qnil; } @@ -991,7 +993,9 @@ rb_io_close_read(io) OpenFile *fptr; int n; - rb_secure(4); + if (rb_safe_level() >= 4 && !OBJ_TAINTED(io)) { + rb_raise(rb_eSecurityError, "Insecure: can't close"); + } GetOpenFile(io, fptr); if (fptr->f2 == 0 && (fptr->mode & FMODE_WRITABLE)) { rb_raise(rb_eIOError, "closing non-duplex IO for reading"); @@ -1015,7 +1019,9 @@ rb_io_close_write(io) OpenFile *fptr; int n; - rb_secure(4); + if (rb_safe_level() >= 4 && !OBJ_TAINTED(io)) { + rb_raise(rb_eSecurityError, "Insecure: can't close"); + } GetOpenFile(io, fptr); if (fptr->f2 == 0 && (fptr->mode & FMODE_READABLE)) { rb_raise(rb_eIOError, "closing non-duplex IO for writing"); @@ -1685,9 +1691,11 @@ rb_io_reopen(io, nfile) char *mode; int fd; - rb_secure(4); - GetOpenFile(io, fptr); nfile = rb_io_get_io(nfile); + if (rb_safe_level() >= 4 && (!OBJ_TAINTED(io) || !OBJ_TAINTED(nfile))) { + rb_raise(rb_eSecurityError, "Insecure: can't reopen"); + } + GetOpenFile(io, fptr); GetOpenFile(nfile, orig); if (fptr == orig) return io; @@ -3070,6 +3078,8 @@ argf_eof() { if (init_p == 0 && !next_argv()) return Qtrue; + if (next_p == -1) + return Qtrue; if (TYPE(current_file) != T_FILE) { return argf_forward(); } |