From: "andrykonchin (Andrew Konchin) via ruby-core" Date: 2023-01-26T14:09:09+00:00 Subject: [ruby-core:112051] [Ruby master Bug#19380] IO.read doesn't validate the offset argument Issue #19380 has been reported by andrykonchin (Andrew Konchin). ---------------------------------------- Bug #19380: IO.read doesn't validate the offset argument https://bugs.ruby-lang.org/issues/19380 * Author: andrykonchin (Andrew Konchin) * Status: Open * Priority: Normal * ruby -v: 3.1.3 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I've noticed that when passed negative `offset` argument `IO.read` raises a bit confusing error: ```ruby 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: ```ruby 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)` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/