зеркало из https://github.com/github/ruby.git
ruby.h: safe_level check
* include/ruby/ruby.h (RUBY_SAFE_LEVEL_CHECK): check constant safe level at compile time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0e76c14085
Коммит
3dbf227ed0
|
@ -1,3 +1,8 @@
|
|||
Thu Jun 13 14:51:06 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* test/-ext-/test_printf.rb, test/rss/test_parser.rb,
|
||||
|
|
|
@ -556,9 +556,20 @@ VALUE rb_get_path(VALUE);
|
|||
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));
|
||||
|
|
5
safe.c
5
safe.c
|
@ -16,13 +16,16 @@
|
|||
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)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче