diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-12 02:27:51 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-12 02:27:51 +0000 |
commit | b3027d5929945a7d08b89af3bb514c9b687b41d0 (patch) | |
tree | 1357a66fefca71c59138ed3c602b2885f25dd017 | |
parent | 7e2f0491ce16d7f15660b0b01be9f23526aa07b9 (diff) | |
download | ruby-b3027d5929945a7d08b89af3bb514c9b687b41d0.tar.gz |
* io.c (rb_ioctl): don't expose our sanity check value to ruby script.
It may change string value meaning if the value is string.
(e.g. MacOS X has F_GETPATH ioctl)
* io.c (rb_fcntl): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | io.c | 12 |
2 files changed, 15 insertions, 4 deletions
@@ -1,3 +1,10 @@ +Sat Nov 12 11:13:18 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * io.c (rb_ioctl): don't expose our sanity check value to ruby script. + It may change string value meaning if the value is string. + (e.g. MacOS X has F_GETPATH ioctl) + * io.c (rb_fcntl): ditto. + Sat Nov 12 11:06:02 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> * io.c (ioctl_req_t): Type of req argument of ioctl() depend on platform. @@ -7973,8 +7973,10 @@ rb_ioctl(VALUE io, VALUE req, VALUE arg) GetOpenFile(io, fptr); retval = do_ioctl(fptr->fd, cmd, narg); if (retval < 0) rb_sys_fail_path(fptr->pathv); - if (RB_TYPE_P(arg, T_STRING) && RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] != 17) { - rb_raise(rb_eArgError, "return value overflowed string"); + if (RB_TYPE_P(arg, T_STRING)) { + if (RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] != 17) + rb_raise(rb_eArgError, "return value overflowed string"); + RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] = '\0'; } return INT2NUM(retval); @@ -8053,8 +8055,10 @@ rb_fcntl(VALUE io, VALUE req, VALUE arg) GetOpenFile(io, fptr); retval = do_fcntl(fptr->fd, cmd, narg); if (retval < 0) rb_sys_fail_path(fptr->pathv); - if (RB_TYPE_P(arg, T_STRING) && RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] != 17) { - rb_raise(rb_eArgError, "return value overflowed string"); + if (RB_TYPE_P(arg, T_STRING)) { + if (RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] != 17) + rb_raise(rb_eArgError, "return value overflowed string"); + RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] = '\0'; } if (cmd == F_SETFL) { |