aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-12 02:06:23 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-12 02:06:23 +0000
commit9d16ad639f49513b720e3afa6809eb98c0a6d609 (patch)
treecb4c8f31180f865728ce0268564669af638b6b23
parentdb48bbdf0b4b8400d4ad0c1df5190d898fd9ed75 (diff)
downloadruby-9d16ad639f49513b720e3afa6809eb98c0a6d609.tar.gz
* io.c (+ioctl_narg_len) new helper function.
* io.c (rb_io_ctl): don't use ioctl specific length check if caller is fcntl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--io.c34
2 files changed, 30 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 43c4eb91aa..2cd36f5c23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Nov 12 10:52:17 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * io.c (+ioctl_narg_len) new helper function.
+ * io.c (rb_io_ctl): don't use ioctl specific length check
+ if caller is fcntl.
+
Fri Nov 11 23:00:46 2011 Tanaka Akira <akr@fsij.org>
* ext/dbm/extconf.rb: db_prefix is not required now.
diff --git a/io.c b/io.c
index e97704db11..8db2e63cac 100644
--- a/io.c
+++ b/io.c
@@ -7909,6 +7909,25 @@ io_cntl(int fd, int cmd, long narg, int io_p)
return retval;
}
+static long
+ioctl_narg_len(int cmd)
+{
+ long len;
+
+#ifdef IOCPARM_MASK
+#ifndef IOCPARM_LEN
+#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
+#endif
+#endif
+#ifdef IOCPARM_LEN
+ len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
+#else
+ len = 256; /* otherwise guess at what's safe */
+#endif
+
+ return len;
+}
+
static VALUE
rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
{
@@ -7937,16 +7956,11 @@ rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
}
else {
arg = tmp;
-#ifdef IOCPARM_MASK
-#ifndef IOCPARM_LEN
-#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
-#endif
-#endif
-#ifdef IOCPARM_LEN
- len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
-#else
- len = 256; /* otherwise guess at what's safe */
-#endif
+
+ if (io_p)
+ ioctl_narg_len(cmd);
+ else
+ len = 256;
rb_str_modify(arg);
if (len <= RSTRING_LEN(arg)) {