Actions
Bug #19380
closedIO.read doesn't validate the offset argument
Description
I've noticed that when passed negative offset
argument IO.read
raises a bit confusing error:
IO.read("read-test.txt", 1, -1)
# (irb):55:in `read': Invalid argument @ rb_io_seek - read-test.txt (Errno::EINVAL)
But error for invalid length
argument is much more helpful:
IO.read("read-test.txt", -1)
# (irb):56:in `read': negative length -1 given (ArgumentError)
I would expect a similar ArgumentError exception to be raised for invalid offset
argument instead of Invalid argument @ rb_io_seek - read-test.txt (Errno::EINVAL)
Actions
Like0
Like0Like0