ruby-changes:49339
From: nagachika <ko1@a...>
Date: Mon, 25 Dec 2017 05:06:39 +0900 (JST)
Subject: [ruby-changes:49339] nagachika:r61456 (ruby_2_4): merge revision(s) 60071: [Backport #13953] [Backport #13954] [Backport #13955] [Backport #13957]
nagachika 2017-12-25 05:06:32 +0900 (Mon, 25 Dec 2017) New Revision: 61456 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61456 Log: merge revision(s) 60071: [Backport #13953] [Backport #13954] [Backport #13955] [Backport #13957] ext: check if null byte is contained [ruby-dev:50267] [Bug #13953] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/ext/bigdecimal/bigdecimal.c branches/ruby_2_4/ext/etc/etc.c branches/ruby_2_4/ext/gdbm/gdbm.c branches/ruby_2_4/ext/nkf/nkf.c branches/ruby_2_4/ext/psych/psych_emitter.c branches/ruby_2_4/ext/readline/readline.c branches/ruby_2_4/ext/syslog/syslog.c branches/ruby_2_4/parse.y branches/ruby_2_4/version.h Index: ruby_2_4/parse.y =================================================================== --- ruby_2_4/parse.y (revision 61455) +++ ruby_2_4/parse.y (revision 61456) @@ -11425,7 +11425,7 @@ ripper_initialize(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L11425 OBJ_FREEZE(fname); } else { - StringValue(fname); + StringValueCStr(fname); fname = rb_str_new_frozen(fname); } parser_initialize(parser); Index: ruby_2_4/ext/nkf/nkf.c =================================================================== --- ruby_2_4/ext/nkf/nkf.c (revision 61455) +++ ruby_2_4/ext/nkf/nkf.c (revision 61456) @@ -137,8 +137,7 @@ rb_nkf_convert(VALUE obj, VALUE opt, VAL https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/nkf/nkf.c#L137 { VALUE tmp; reinit(); - StringValue(opt); - nkf_split_options(RSTRING_PTR(opt)); + nkf_split_options(StringValueCStr(opt)); if (!output_encoding) rb_raise(rb_eArgError, "no output encoding given"); switch (nkf_enc_to_index(output_encoding)) { @@ -153,8 +152,7 @@ rb_nkf_convert(VALUE obj, VALUE opt, VAL https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/nkf/nkf.c#L152 incsize = INCSIZE; input_ctr = 0; - StringValue(src); - input = (unsigned char *)RSTRING_PTR(src); + input = (unsigned char *)StringValuePtr(src); i_len = RSTRING_LENINT(src); tmp = rb_str_new(0, i_len*3 + 10); @@ -195,8 +193,7 @@ rb_nkf_guess(VALUE obj, VALUE src) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/nkf/nkf.c#L193 reinit(); input_ctr = 0; - StringValue(src); - input = (unsigned char *)RSTRING_PTR(src); + input = (unsigned char *)StringValuePtr(src); i_len = RSTRING_LENINT(src); guess_f = TRUE; Index: ruby_2_4/ext/syslog/syslog.c =================================================================== --- ruby_2_4/ext/syslog/syslog.c (revision 61455) +++ ruby_2_4/ext/syslog/syslog.c (revision 61456) @@ -150,6 +150,7 @@ static VALUE mSyslog_close(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/syslog/syslog.c#L150 static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self) { VALUE ident, opt, fac; + const char *ident_ptr; if (syslog_opened) { rb_raise(rb_eRuntimeError, "syslog already open"); @@ -160,8 +161,9 @@ static VALUE mSyslog_open(int argc, VALU https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/syslog/syslog.c#L161 if (NIL_P(ident)) { ident = rb_gv_get("$0"); } - SafeStringValue(ident); - syslog_ident = strdup(RSTRING_PTR(ident)); + ident_ptr = StringValueCStr(ident); + rb_check_safe_obj(ident); + syslog_ident = strdup(ident_ptr); if (NIL_P(opt)) { syslog_options = LOG_PID | LOG_CONS; Index: ruby_2_4/ext/bigdecimal/bigdecimal.c =================================================================== --- ruby_2_4/ext/bigdecimal/bigdecimal.c (revision 61455) +++ ruby_2_4/ext/bigdecimal/bigdecimal.c (revision 61456) @@ -288,8 +288,9 @@ again: https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/bigdecimal/bigdecimal.c#L288 #ifdef ENABLE_NUMERIC_STRING case T_STRING: - SafeStringValue(v); - return VpCreateRbObject(strlen(RSTRING_PTR(v)) + VpBaseFig() + 1, + StringValueCStr(v); + rb_check_safe_obj(v); + return VpCreateRbObject(RSTRING_LEN(v) + VpBaseFig() + 1, RSTRING_PTR(v)); #endif /* ENABLE_NUMERIC_STRING */ @@ -428,8 +429,8 @@ BigDecimal_load(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/bigdecimal/bigdecimal.c#L429 unsigned char ch; unsigned long m=0; - SafeStringValue(str); - pch = (unsigned char *)RSTRING_PTR(str); + pch = (unsigned char *)StringValueCStr(str); + rb_check_safe_obj(str); /* First get max prec */ while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') { if(!ISDIGIT(ch)) { @@ -2015,8 +2016,8 @@ BigDecimal_to_s(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/bigdecimal/bigdecimal.c#L2016 if (rb_scan_args(argc, argv, "01", &f) == 1) { if (RB_TYPE_P(f, T_STRING)) { - SafeStringValue(f); - psz = RSTRING_PTR(f); + psz = StringValueCStr(f); + rb_check_safe_obj(f); if (*psz == ' ') { fPlus = 1; psz++; Index: ruby_2_4/ext/psych/psych_emitter.c =================================================================== --- ruby_2_4/ext/psych/psych_emitter.c (revision 61455) +++ ruby_2_4/ext/psych/psych_emitter.c (revision 61456) @@ -192,8 +192,8 @@ static VALUE start_document(VALUE self, https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/psych/psych_emitter.c#L192 name = rb_str_export_to_enc(name, encoding); value = rb_str_export_to_enc(value, encoding); - tail->handle = (yaml_char_t *)RSTRING_PTR(name); - tail->prefix = (yaml_char_t *)RSTRING_PTR(value); + tail->handle = (yaml_char_t *)StringValueCStr(name); + tail->prefix = (yaml_char_t *)StringValueCStr(value); tail++; } Index: ruby_2_4/ext/etc/etc.c =================================================================== --- ruby_2_4/ext/etc/etc.c (revision 61455) +++ ruby_2_4/ext/etc/etc.c (revision 61456) @@ -215,9 +215,10 @@ etc_getpwnam(VALUE obj, VALUE nam) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/etc/etc.c#L215 { #ifdef HAVE_GETPWENT struct passwd *pwd; + const char *p = StringValueCStr(nam); - SafeStringValue(nam); - pwd = getpwnam(RSTRING_PTR(nam)); + rb_check_safe_obj(nam); + pwd = getpwnam(p); if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam); return setup_passwd(pwd); #else @@ -458,9 +459,10 @@ etc_getgrnam(VALUE obj, VALUE nam) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/etc/etc.c#L459 { #ifdef HAVE_GETGRENT struct group *grp; + const char *p = StringValueCStr(nam); - SafeStringValue(nam); - grp = getgrnam(RSTRING_PTR(nam)); + rb_check_safe_obj(nam); + grp = getgrnam(p); if (grp == 0) rb_raise(rb_eArgError, "can't find group for %"PRIsVALUE, nam); return setup_group(grp); #else Index: ruby_2_4/ext/readline/readline.c =================================================================== --- ruby_2_4/ext/readline/readline.c (revision 61455) +++ ruby_2_4/ext/readline/readline.c (revision 61456) @@ -92,7 +92,8 @@ static char **readline_attempted_complet https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/readline/readline.c#L92 int start, int end); #define OutputStringValue(str) do {\ - SafeStringValue(str);\ + StringValueCStr(str);\ + rb_check_safe_obj(str);\ (str) = rb_str_conv_enc((str), rb_enc_get(str), rb_locale_encoding());\ } while (0)\ Index: ruby_2_4/ext/gdbm/gdbm.c =================================================================== --- ruby_2_4/ext/gdbm/gdbm.c (revision 61455) +++ ruby_2_4/ext/gdbm/gdbm.c (revision 61456) @@ -228,7 +228,7 @@ fgdbm_initialize(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/gdbm/gdbm.c#L228 if (!NIL_P(vflags)) flags = NUM2INT(vflags); - SafeStringValue(file); + FilePathValue(file); #ifdef GDBM_CLOEXEC /* GDBM_CLOEXEC is available since gdbm 1.10. */ Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 61455) +++ ruby_2_4/version.h (revision 61456) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" #define RUBY_RELEASE_DATE "2017-12-25" -#define RUBY_PATCHLEVEL 226 +#define RUBY_PATCHLEVEL 227 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 12 Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 61455) +++ ruby_2_4 (revision 61456) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r60071 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/