[#111712] [Ruby master Feature#19322] Support spawning "private" child processes — "kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core" <ruby-core@...>
SXNzdWUgIzE5MzIyIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGtqdHNhbmFrdHNpZGlzIChLSiBUc2Fu
14 messages
2023/01/07
[ruby-core:112051] [Ruby master Bug#19380] IO.read doesn't validate the offset argument
From:
"andrykonchin (Andrew Konchin) via ruby-core" <ruby-core@...>
Date:
2023-01-26 14:09:09 UTC
List:
ruby-core #112051
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/