ruby-changes:58214
From: Yusuke <ko1@a...>
Date: Fri, 11 Oct 2019 21:49:14 +0900 (JST)
Subject: [ruby-changes:58214] c866663784 (master): io.c (NUM2IOCTLREQ): Accept a value more than INT_MAX
https://git.ruby-lang.org/ruby.git/commit/?id=c866663784 From c866663784ea5a8f16e7fe5127127fb46ae90e6e Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Fri, 11 Oct 2019 21:43:18 +0900 Subject: io.c (NUM2IOCTLREQ): Accept a value more than INT_MAX ioctl accepts int as request arguments on some platforms, but some requests are more than INT_MAX, e.g., RNDGETENTCNT(0x80045200). Passing (0x80045200 | (-1 << 32)) may work around the issue, but it may not work on a platform where ioctl accepts unsigned long. So this change uses NUM2LONG and then casts it to int. diff --git a/io.c b/io.c index 2de3ceb..33350ea 100644 --- a/io.c +++ b/io.c @@ -9565,7 +9565,7 @@ rb_f_select(int argc, VALUE *argv, VALUE obj) https://github.com/ruby/ruby/blob/trunk/io.c#L9565 # define NUM2IOCTLREQ(num) NUM2ULONG(num) #else typedef int ioctl_req_t; -# define NUM2IOCTLREQ(num) NUM2INT(num) +# define NUM2IOCTLREQ(num) ((int)NUM2LONG(num)) #endif #ifdef HAVE_IOCTL -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/