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

ruby-changes:28836

From: nobu <ko1@a...>
Date: Wed, 22 May 2013 15:19:13 +0900 (JST)
Subject: [ruby-changes:28836] nobu:r40888 (trunk): win32.c: check error of SetFilePointer

nobu	2013-05-22 15:19:03 +0900 (Wed, 22 May 2013)

  New Revision: 40888

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

  Log:
    win32.c: check error of SetFilePointer
    
    * win32/win32.c (setup_overlapped): check the error code in addition
      to the result of SetFilePointer() to determine if an error occurred,
      because INVALID_SET_FILE_POINTER is a valid value.
      [ruby-core:55098] [Bug #8431]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_io.rb
    trunk/win32/win32.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40887)
+++ ChangeLog	(revision 40888)
@@ -1,4 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Wed May 22 15:17:30 2013  Nobuyoshi Nakada  <nobu@r...>
+Wed May 22 15:18:59 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/win32.c (setup_overlapped): check the error code in addition
+	  to the result of SetFilePointer() to determine if an error occurred,
+	  because INVALID_SET_FILE_POINTER is a valid value.
+	  [ruby-core:55098] [Bug #8431]
 
 	* win32/win32.c (setup_overlapped, finish_overlapped): extract from
 	  rb_w32_read() and rb_w32_write().
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 40887)
+++ win32/win32.c	(revision 40888)
@@ -6028,8 +6028,11 @@ setup_overlapped(OVERLAPPED *ol, int fd) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6028
 #define INVALID_SET_FILE_POINTER ((DWORD)-1)
 #endif
 	if (low == INVALID_SET_FILE_POINTER) {
-	    errno = map_errno(GetLastError());
-	    return -1;
+	    DWORD err = GetLastError();
+	    if (err != NO_ERROR) {
+		errno = map_errno(err);
+		return -1;
+	    }
 	}
 	ol->Offset = low;
 	ol->OffsetHigh = high;
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 40887)
+++ test/ruby/test_io.rb	(revision 40888)
@@ -2673,4 +2673,15 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2673
       IO.select(tempfiles)
   }, bug8080
   end
+
+  def test_seek_32bit_boundary
+    bug8431 = '[ruby-core:55098] [Bug #8431]'
+    make_tempfile {|t|
+      assert_ruby_status(["-e", <<-"end;", t.path], "", bug8431)
+        f = ARGF.to_io
+        f.seek(0xffff_ffff)
+        f.read(1)
+      end;
+    }
+  end
 end

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

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