ruby-changes:29221
From: nobu <ko1@a...>
Date: Thu, 13 Jun 2013 14:51:25 +0900 (JST)
Subject: [ruby-changes:29221] nobu:r41273 (trunk): ruby.h: safe_level check
nobu 2013-06-13 14:51:14 +0900 (Thu, 13 Jun 2013) New Revision: 41273 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41273 Log: ruby.h: safe_level check * include/ruby/ruby.h (RUBY_SAFE_LEVEL_CHECK): check constant safe level at compile time. Modified files: trunk/ChangeLog trunk/include/ruby/ruby.h trunk/safe.c Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 41272) +++ include/ruby/ruby.h (revision 41273) @@ -556,9 +556,20 @@ VALUE rb_get_path(VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L556 VALUE rb_get_path_no_checksafe(VALUE); #define FilePathStringValue(v) ((v) = rb_get_path_no_checksafe(v)) +#define RUBY_SAFE_LEVEL_MAX 3 void rb_secure(int); int rb_safe_level(void); void rb_set_safe_level(int); +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) +int ruby$safe_level$4(void) __attribute__((error("$SAFE=4 is obsolete"))); +#define RUBY_SAFE_LEVEL_INVALID_P(level) \ + __extension__(__builtin_constant_p(level) && \ + ((level) < 0 || RUBY_SAFE_LEVEL_MAX < (level))) +#define RUBY_SAFE_LEVEL_CHECK(level) \ + (RUBY_SAFE_LEVEL_INVALID_P(level) ? ruby$safe_level$4() : 0) +#define rb_secure(level) (RUBY_SAFE_LEVEL_CHECK(level), rb_secure(level)) +#define rb_set_safe_level(level) (RUBY_SAFE_LEVEL_CHECK(level), rb_set_safe_level(level)) +#endif void rb_set_safe_level_force(int); void rb_secure_update(VALUE); NORETURN(void rb_insecure_operation(void)); Index: ChangeLog =================================================================== --- ChangeLog (revision 41272) +++ ChangeLog (revision 41273) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jun 13 14:51:06 2013 Nobuyoshi Nakada <nobu@r...> + + * include/ruby/ruby.h (RUBY_SAFE_LEVEL_CHECK): check constant safe + level at compile time. + Thu Jun 13 14:39:08 2013 Shugo Maeda <shugo@r...> * test/-ext-/test_printf.rb, test/rss/test_parser.rb, Index: safe.c =================================================================== --- safe.c (revision 41272) +++ safe.c (revision 41273) @@ -16,13 +16,16 @@ https://github.com/ruby/ruby/blob/trunk/safe.c#L16 3 - all generated objects are tainted */ -#define SAFE_LEVEL_MAX 3 +#define SAFE_LEVEL_MAX RUBY_SAFE_LEVEL_MAX #include "ruby/ruby.h" #include "vm_core.h" /* $SAFE accessor */ +#undef rb_secure +#undef rb_set_safe_level + int rb_safe_level(void) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/