summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-29 15:58:18 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-29 15:58:18 +0000
commitc0acb3ce179ff038ee24f608a3615069645a7799 (patch)
tree86c583626c2dee0f1c4fdafab877423cd0af7b60 /io.c
parentcb32ebe81c0d02a430d016cbdfd93960ec0b259d (diff)
downloadruby-c0acb3ce179ff038ee24f608a3615069645a7799.tar.gz
* io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992]
* lib/ostruct.rb (OpenStruct::method_missing): check method duplication for -d. * lib/ostruct.rb (OpenStruct::initialize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/io.c b/io.c
index b9b2c78f3c..6fdd9e9466 100644
--- a/io.c
+++ b/io.c
@@ -2321,13 +2321,19 @@ rb_io_sysread(argc, argv, io)
if (READ_DATA_BUFFERED(fptr->f)) {
rb_raise(rb_eIOError, "sysread for buffered IO");
}
+ rb_str_locktmp(str);
+
n = fileno(fptr->f);
rb_thread_wait_fd(fileno(fptr->f));
rb_io_check_closed(fptr);
+ if (RSTRING(str)->len != ilen) {
+ rb_raise(rb_eRuntimeError, "buffer string modified");
+ }
TRAP_BEG;
- n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
+ n = read(fileno(fptr->f), RSTRING(str)->ptr, ilen);
TRAP_END;
+ rb_str_unlocktmp(str);
if (n == -1) {
rb_str_resize(str, 0);
rb_sys_fail(fptr->path);