diff options
-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) { |