From 52b497d8b7f5f05b7420b8200423304bb0c85ef9 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 19 Jun 2012 08:51:57 +0000 Subject: [PATCH] process.c: no method calls in async-signal-safe * process.c (rb_execarg_run_options): do not call any methods in the async-signal-safe function. mask has been checked with NUM2MODET() already and converted with LONG2NUM(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ process.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 860c76e448..3be62ecc21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Jun 19 17:51:54 2012 Nobuyoshi Nakada + + * process.c (rb_execarg_run_options): do not call any methods in the + async-signal-safe function. mask has been checked with NUM2MODET() + already and converted with LONG2NUM(). + Tue Jun 19 11:59:56 2012 NARUSE, Yui * ext/readline/readline.c (Init_readline): don't set 0 to diff --git a/process.c b/process.c index 41206e180a..999a37e435 100644 --- a/process.c +++ b/process.c @@ -17,6 +17,8 @@ #include "internal.h" #include "vm_core.h" +#define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)] + #include #include #include @@ -1595,6 +1597,7 @@ rb_execarg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val) hide_obj(rb_str_dup(val))); } else if (id == rb_intern("umask")) { + STATIC_ASSERT(sizeof_mode_t, sizeof(long) >= sizeof(mode_t)); /* for LONG2NUM */ mode_t cmask = NUM2MODET(val); if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_UMASK))) { rb_raise(rb_eArgError, "umask option specified twice"); @@ -2707,7 +2710,7 @@ rb_execarg_run_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char obj = rb_ary_entry(options, EXEC_OPTION_UMASK); if (!NIL_P(obj)) { - mode_t mask = NUM2MODET(obj); + mode_t mask = (mode_t)FIX2LONG(obj); /* no method calls */ mode_t oldmask = umask(mask); /* never fail */ /* async-signal-safe */ if (!NIL_P(soptions)) rb_ary_store(soptions, EXEC_OPTION_UMASK, MODET2NUM(oldmask));