ruby-changes:57255
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 26 Aug 2019 13:04:06 +0900 (JST)
Subject: [ruby-changes:57255] 卜部昌平: 5e86b005c0 (master): uid_t and gid_t are narrower than VALUE.
https://git.ruby-lang.org/ruby.git/commit/?id=5e86b005c0 From 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Fri, 23 Aug 2019 12:14:06 +0900 Subject: uid_t and gid_t are narrower than VALUE. Often uid / gid are 16 bit or 32 bit integers, while VALUE are 32 to 64 bits. They tend to differ in size. Because rb_ensure expects its callbacks to take VALUE arguments, narrowing must be done by hand, otherwise data corruption can happen depending on machine ABI. diff --git a/process.c b/process.c index db3f38d..8cd42db 100644 --- a/process.c +++ b/process.c @@ -7133,8 +7133,9 @@ p_uid_have_saved_id(void) https://github.com/ruby/ruby/blob/trunk/process.c#L7133 #if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS) static VALUE -p_uid_sw_ensure(rb_uid_t id) +p_uid_sw_ensure(VALUE i) { + rb_uid_t id = (rb_uid_t/* narrowing */)i; under_uid_switch = 0; id = rb_seteuid_core(id); return UIDT2NUM(id); @@ -7246,8 +7247,9 @@ p_gid_have_saved_id(void) https://github.com/ruby/ruby/blob/trunk/process.c#L7247 #if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS) static VALUE -p_gid_sw_ensure(rb_gid_t id) +p_gid_sw_ensure(VALUE i) { + rb_gid_t id = (rb_gid_t/* narrowing */)i; under_gid_switch = 0; id = rb_setegid_core(id); return GIDT2NUM(id); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/