Issue #8431 has been updated by phasis68 (Heesob Park).


The change set r40888 is not complete.
As I pointed out the above patch, there are two SetFilePointer checking.
The invalid SetFilePointer check is still remains in the rb_w32_write function.

Here is write part segfault.

C:\Users\phasis>irb
DL is deprecated, please use Fiddle
irb(main):001:0> f = File.open('a','wb')
=> #<File:a>
irb(main):002:0> f.seek(0xffffffff)
=> 0
irb(main):003:0> f.write('1')
=> 1
irb(main):004:0> f.tell
(irb):4: [BUG] rb_sys_fail() - errno == 0
ruby 2.0.0p195 (2013-05-14) [i386-mingw32]

-- Control frame information -----------------------------------------------
c:0019 p:---- s:0075 e:000074 CFUNC  :tell
c:0018 p:0006 s:0072 e:000071 EVAL   (irb):4 [FINISH]
c:0017 p:---- s:0070 e:000069 CFUNC  :eval
c:0016 p:0024 s:0063 e:000062 METHOD C:/Ruby200/lib/ruby/2.0.0/irb/workspace.rb:
86
c:0015 p:0025 s:0056 e:000054 METHOD C:/Ruby200/lib/ruby/2.0.0/irb/context.rb:38
0
c:0014 p:0022 s:0050 e:000049 BLOCK  C:/Ruby200/lib/ruby/2.0.0/irb.rb:492
c:0013 p:0040 s:0042 e:000041 METHOD C:/Ruby200/lib/ruby/2.0.0/irb.rb:624
c:0012 p:0009 s:0037 e:000036 BLOCK  C:/Ruby200/lib/ruby/2.0.0/irb.rb:489
c:0011 p:0118 s:0033 e:000032 BLOCK  C:/Ruby200/lib/ruby/2.0.0/irb/ruby-lex.rb:2
47 [FINISH]
c:0010 p:---- s:0030 e:000029 CFUNC  :loop
c:0009 p:0007 s:0027 e:000026 BLOCK  C:/Ruby200/lib/ruby/2.0.0/irb/ruby-lex.rb:2
33 [FINISH]
c:0008 p:---- s:0025 e:000024 CFUNC  :catch
c:0007 p:0015 s:0021 e:000020 METHOD C:/Ruby200/lib/ruby/2.0.0/irb/ruby-lex.rb:2
32
c:0006 p:0030 s:0018 E:000564 METHOD C:/Ruby200/lib/ruby/2.0.0/irb.rb:488
c:0005 p:0008 s:0015 e:000014 BLOCK  C:/Ruby200/lib/ruby/2.0.0/irb.rb:397 [FINIS
H]
c:0004 p:---- s:0013 e:000012 CFUNC  :catch
c:0003 p:0143 s:0009 E:0000d4 METHOD C:/Ruby200/lib/ruby/2.0.0/irb.rb:396
c:0002 p:0031 s:0004 E:001d0c EVAL   C:/Ruby200/bin/irb:12 [FINISH]
c:0001 p:0000 s:0002 E:0023dc TOP    [FINISH]

C:/Ruby200/bin/irb:12:in `<main>'
C:/Ruby200/lib/ruby/2.0.0/irb.rb:396:in `start'
C:/Ruby200/lib/ruby/2.0.0/irb.rb:396:in `catch'
C:/Ruby200/lib/ruby/2.0.0/irb.rb:397:in `block in start'
C:/Ruby200/lib/ruby/2.0.0/irb.rb:488:in `eval_input'
C:/Ruby200/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `each_top_level_statement'
C:/Ruby200/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `catch'
C:/Ruby200/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `block in each_top_level_statem
ent'
C:/Ruby200/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `loop'
C:/Ruby200/lib/ruby/2.0.0/irb/ruby-lex.rb:247:in `block (2 levels) in each_top_l
evel_statement'
C:/Ruby200/lib/ruby/2.0.0/irb.rb:489:in `block in eval_input'
C:/Ruby200/lib/ruby/2.0.0/irb.rb:624:in `signal_status'
C:/Ruby200/lib/ruby/2.0.0/irb.rb:492:in `block (2 levels) in eval_input'
C:/Ruby200/lib/ruby/2.0.0/irb/context.rb:380:in `evaluate'
C:/Ruby200/lib/ruby/2.0.0/irb/workspace.rb:86:in `evaluate'
C:/Ruby200/lib/ruby/2.0.0/irb/workspace.rb:86:in `eval'
(irb):4:in `irb_binding'
(irb):4:in `tell'

----------------------------------------
Backport #8431: File.read() crash on Win32SP3 32bit
https://bugs.ruby-lang.org/issues/8431#change-39480

Author: galnaktar (Oleg K)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


Open existing empty file, seek on 0xFFFFFFFF(4294967295) and trying to read 1 byte.


c:\Ruby200\bin>irb
DL is deprecated, please use Fiddle
irb(main):001:0> f = File.open("1", "w")
=> #<File:1>
irb(main):002:0> f.close
=> nil
irb(main):003:0> f = File.open("1", "rb")
=> #<File:1>
irb(main):004:0> f.seek(4294967295)
=> 0
irb(main):005:0> f.read(1)
(irb):5: [BUG] rb_sys_fail_str(1) - errno == 0
ruby 2.0.0p195 (2013-05-14) [i386-mingw32]

-- Control frame information -----------------------------------------------
c:0019 p:---- s:0076 e:000075 CFUNC  :read
c:0018 p:0007 s:0072 e:000071 EVAL   (irb):5 [FINISH]
c:0017 p:---- s:0070 e:000069 CFUNC  :eval
c:0016 p:0024 s:0063 e:000062 METHOD c:/Ruby200/lib/ruby/2.0.0/irb/workspace.rb:


-- 
http://bugs.ruby-lang.org/