aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--io.c12
2 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 83ea9eac71..06dee3962f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/io.c b/io.c
index d0aceb2c89..38638a18db 100644
--- a/io.c
+++ b/io.c
@@ -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) {