summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--file.c3
-rw-r--r--test/ruby/test_file.rb10
-rw-r--r--version.h2
4 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a93d46b..d3fa1ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Oct 12 18:19:35 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (rb_get_path_check): path name must not contain NUL bytes.
+
Fri Oct 12 17:51:43 2012 Shugo Maeda <shugo@ruby-lang.org>
* error.c (exc_to_s, name_err_to_s, name_err_mesg_to_str): do not
diff --git a/file.c b/file.c
index 2659ef7..eead657 100644
--- a/file.c
+++ b/file.c
@@ -176,6 +176,9 @@ rb_get_path_check(VALUE obj, int level)
rb_raise(rb_eEncCompatError, "path name must be ASCII-compatible (%s): %s",
rb_enc_name(enc), RSTRING_PTR(tmp));
}
+
+ StringValueCStr(tmp);
+
return rb_str_new4(tmp);
}
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index 26f68df..b888233 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -260,4 +260,14 @@ class TestFile < Test::Unit::TestCase
assert_equal(File.chmod(0666, file), 1, bug5671)
end
end
+
+ def test_open_nul
+ Dir.mktmpdir(__method__.to_s) do |tmpdir|
+ path = File.join(tmpdir, "foo")
+ assert_raise(ArgumentError) do
+ open(path + "\0bar", "w") {}
+ end
+ refute File.exist?(path)
+ end
+ end
end
diff --git a/version.h b/version.h
index dcec0e8..79574eb 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 285
+#define RUBY_PATCHLEVEL 286
#define RUBY_RELEASE_DATE "2012-10-12"
#define RUBY_RELEASE_YEAR 2012