summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ruby.c4
-rw-r--r--test/ruby/test_rubyoptions.rb7
2 files changed, 10 insertions, 1 deletions
diff --git a/ruby.c b/ruby.c
index 7e64d081a9..d0f66dcd6d 100644
--- a/ruby.c
+++ b/ruby.c
@@ -2186,7 +2186,9 @@ external_str_new_cstr(const char *p)
{
#if UTF8_PATH
VALUE str = rb_utf8_str_new_cstr(p);
- return str_conv_enc(str, NULL, rb_default_external_encoding());
+ str = str_conv_enc(str, NULL, rb_default_external_encoding());
+ OBJ_TAINT_RAW(str);
+ return str;
#else
return rb_external_str_new_cstr(p);
#endif
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 2d50adc9aa..0e6a9b8fe3 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -1068,6 +1068,13 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err([IO::NULL], success: true)
end
+ def test_argv_tainted
+ assert_separately(%w[- arg], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ assert_predicate(ARGV[0], :tainted?, '[ruby-dev:50596] [Bug #14941]')
+ end;
+ end
+
private
def mjit_force_enabled?