1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/etc] Remove taint support

Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.

Still untaint the tmpdir object on Ruby <2.7, as returning
a tainted string there could cause problems.
This commit is contained in:
Jeremy Evans 2019-10-18 12:10:03 -07:00
parent 23f1fb0663
commit 398cd3cc7d
Notes: git 2019-11-18 08:01:13 +09:00

View file

@ -100,7 +100,7 @@ static VALUE
safe_setup_str(const char *str)
{
if (str == 0) str = "";
return rb_tainted_str_new2(str);
return rb_str_new2(str);
}
static VALUE
@ -219,7 +219,6 @@ etc_getpwnam(VALUE obj, VALUE nam)
struct passwd *pwd;
const char *p = StringValueCStr(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);
@ -463,7 +462,6 @@ etc_getgrnam(VALUE obj, VALUE nam)
struct group *grp;
const char *p = StringValueCStr(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);
@ -679,7 +677,10 @@ etc_systmpdir(VALUE _)
}
# endif
#endif
#ifndef RB_PASS_KEYWORDS
/* untaint on Ruby < 2.7 */
FL_UNSET(tmpdir, FL_TAINT);
#endif
return tmpdir;
}