hybridgroup / rubyserial

FFI Ruby library for RS-232 serial port communication
https://rubygems.org/gems/rubyserial
Other
154 stars 27 forks source link

Windows not correctly handling number of bytes read #19

Closed planteen closed 9 years ago

planteen commented 9 years ago

If reading 723 bytes (0x2d3) from the serial port, the interpreted value from the .unpack(H4) processing will be 0xd302 (54018 bytes), causing an out-of-bounds crash in the buff.get_bytes call. Issue found on 64-bit Windows 7 with Ruby 2.0.0

planteen commented 9 years ago

Pull request to fix here: https://github.com/hybridgroup/rubyserial/pull/18

planteen commented 9 years ago

Error message: IndexError: Memory access offset=0 size=54018 is out of bounds get_bytes at org/jruby/ext/ffi/AbstractMemory.java:1880 read at C:/jruby-1.7.18/lib/ruby/gems/shared/gems/rubyserial-0.2.1/lib/rubyserial/windows.rb:50

zankich commented 9 years ago

The fix has been pushed in 0.2.2