[ruby-core:102752] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)"
From:
merch-redmine@...
Date:
2021-03-05 23:14:23 UTC
List:
ruby-core #102752
Issue #17673 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Feedback
I tried your example and was unable to reproduce your problem:
```ruby
filePath = 'test.txt'
File.binwrite(filePath, "\x1A\x45")
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
# => ["1a45"]
```
Can you try on a different machine to check if this is a local problem?
----------------------------------------
Bug #17673: sysseek(0) and '1A' in header return "EOFError (end of file reached)"
https://bugs.ruby-lang.org/issues/17673#change-90765
* Author: stiuna (Juan Gregorio)
* Status: Feedback
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
The first byte of my file starts with the value **'1A'** .
Then:
``` ruby
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
#=> "EOFError (end of file reached)"
```
But when I change the first byte of my file to **'AA'** for example.
Then:
``` ruby
#=> "aa45"
```
Is it a bug or am I missing something? I thought sysseek only changed the cursor and nothing else.
This error only occurs with byte **'1A'** I did the test with the rest of the bytes **[00..FF]** and there is no problem except with **'1A'** .
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>