Bug #18880
closedIO#sysread on Windows does not validate arguments
Description
When passing an invalid number of bytes to read, such as -1
, to IO#sysread
on Linux, an ArgumentError
is raised. On Windows Errno::EINVAL
is raised instead.
r, w = IO.pipe
r.sysread(-1)
This raises ArgumentError
on non-Windows and Errno::EINVAL
on Windows.
Updated by javanthropus (Jeremy Bopp) about 2 years ago
I'm interested in submitting a patch for this, but which behavior is considered correct?
Updated by nobu (Nobuyoshi Nakada) about 2 years ago
The ArgumentError
is correct.
Even on Windows, sysread(-2)
raises an ArgumentError
too.
At rounding up len
in io.c:io_setstrbuf(), negative values are not considered.
Updated by javanthropus (Jeremy Bopp) about 2 years ago
I submitted PR https://github.com/ruby/ruby/pull/6354 with a simple fix. I don't have a Windows system to test with though, so I couldn't verify that it works.
Updated by javanthropus (Jeremy Bopp) about 2 years ago
- Status changed from Open to Closed
Applied in changeset git|684353fc03afd6e7c887b65bd18f0b3aeb98101c.
[Win32] Negative length IO#sysread
Raise ArgumentError
in IO#sysread
on Windows when given a negative
length.
Fixes [Bug #18880]