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

ruby-changes:31880

From: nagachika <ko1@a...>
Date: Mon, 2 Dec 2013 23:06:48 +0900 (JST)
Subject: [ruby-changes:31880] nagachika:r43959 (ruby_2_0_0): merge revision(s) 43853: [Backport #9157]

nagachika	2013-12-02 23:06:39 +0900 (Mon, 02 Dec 2013)

  New Revision: 43959

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

  Log:
    merge revision(s) 43853: [Backport #9157]
    
    * file.c (rb_readlink): fix buffer overflow on a long symlink. since
      rb_str_modify_expand() expands from its length but not its capacity,
      need to set the length properly for each expansion.
      [ruby-core:58592] [Bug #9157]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/file.c
    branches/ruby_2_0_0/test/ruby/test_file_exhaustive.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 43958)
+++ ruby_2_0_0/ChangeLog	(revision 43959)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Dec  2 22:53:05 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (rb_readlink): fix buffer overflow on a long symlink. since
+	  rb_str_modify_expand() expands from its length but not its capacity,
+	  need to set the length properly for each expansion.
+	  [ruby-core:58592] [Bug #9157]
+
 Fri Nov 29 00:31:46 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (Doxyfile): tool/file2lastrev.rb needs running with
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 43958)
+++ ruby_2_0_0/version.h	(revision 43959)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2013-11-29"
-#define RUBY_PATCHLEVEL 354
+#define RUBY_RELEASE_DATE "2013-12-02"
+#define RUBY_PATCHLEVEL 355
 
 #define RUBY_RELEASE_YEAR 2013
-#define RUBY_RELEASE_MONTH 11
-#define RUBY_RELEASE_DAY 29
+#define RUBY_RELEASE_MONTH 12
+#define RUBY_RELEASE_DAY 2
 
 #include "ruby/version.h"
 
Index: ruby_2_0_0/test/ruby/test_file_exhaustive.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_file_exhaustive.rb	(revision 43958)
+++ ruby_2_0_0/test/ruby/test_file_exhaustive.rb	(revision 43959)
@@ -391,6 +391,24 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_file_exhaustive.rb#L391
   rescue NotImplementedError
   end
 
+  def test_readlink_long_path
+    return unless @symlinkfile
+    bug9157 = '[ruby-core:58592] [Bug #9157]'
+    assert_separately(["-", @symlinkfile, bug9157], <<-"end;")
+      symlinkfile, bug9157 = *ARGV
+      100.step(1000, 100) do |n|
+        File.unlink(symlinkfile)
+        link = "foo"*n
+        begin
+          File.symlink(link, symlinkfile)
+        rescue Errno::ENAMETOOLONG
+          break
+        end
+        assert_equal(link, File.readlink(symlinkfile), bug9157)
+      end
+    end;
+  end
+
   def test_unlink
     assert_equal(1, File.unlink(@file))
     make_file("foo", @file)
Index: ruby_2_0_0/file.c
===================================================================
--- ruby_2_0_0/file.c	(revision 43958)
+++ ruby_2_0_0/file.c	(revision 43959)
@@ -2531,6 +2531,7 @@ rb_readlink(VALUE path) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/file.c#L2531
 	) {
 	rb_str_modify_expand(v, size);
 	size *= 2;
+	rb_str_set_len(v, size);
     }
     if (rv < 0) {
 	rb_str_resize(v, 0);

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r43853


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

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