[前][次][番号順一覧][スレッド一覧]

ruby-changes:25111

From: nobu <ko1@a...>
Date: Fri, 12 Oct 2012 18:18:20 +0900 (JST)
Subject: [ruby-changes:25111] nobu:r37163 (trunk): file.c: poisoned NUL

nobu	2012-10-12 18:18:07 +0900 (Fri, 12 Oct 2012)

  New Revision: 37163

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37163

  Log:
    file.c: poisoned NUL
    
    * file.c (rb_get_path_check): path name must not contain NUL bytes.

  Modified files:
    trunk/ChangeLog
    trunk/file.c
    trunk/test/ruby/test_file.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37162)
+++ ChangeLog	(revision 37163)
@@ -1,3 +1,7 @@
+Fri Oct 12 18:18:03 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (rb_get_path_check): path name must not contain NUL bytes.
+
 Fri Oct 12 16:06:20 2012  NAKAMURA Usaku  <usa@r...>
 
 	* tool/merger.rb: now can merge revision(s) without --ticket again.
Index: test/ruby/test_file.rb
===================================================================
--- test/ruby/test_file.rb	(revision 37162)
+++ test/ruby/test_file.rb	(revision 37163)
@@ -349,4 +349,14 @@
       end
     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
+      assert_file_not(:exist?, path)
+    end
+  end
 end
Index: file.c
===================================================================
--- file.c	(revision 37162)
+++ file.c	(revision 37163)
@@ -184,6 +184,9 @@
 	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);
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]