ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:109054] [Ruby master Bug#18880] IO#sysread on Windows does not validate arguments
@ 2022-06-26 16:26 javanthropus (Jeremy Bopp)
  2022-09-04 23:13 ` [ruby-core:109843] " javanthropus (Jeremy Bopp)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: javanthropus (Jeremy Bopp) @ 2022-06-26 16:26 UTC (permalink / raw)
  To: ruby-core

Issue #18880 has been reported by javanthropus (Jeremy Bopp).

----------------------------------------
Bug #18880: IO#sysread on Windows does not validate arguments
https://bugs.ruby-lang.org/issues/18880

* Author: javanthropus (Jeremy Bopp)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
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.

``` ruby
r, w = IO.pipe
r.sysread(-1)
```

This raises `ArgumentError` on non-Windows and `Errno::EINVAL` on Windows.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:109843] [Ruby master Bug#18880] IO#sysread on Windows does not validate arguments
  2022-06-26 16:26 [ruby-core:109054] [Ruby master Bug#18880] IO#sysread on Windows does not validate arguments javanthropus (Jeremy Bopp)
@ 2022-09-04 23:13 ` javanthropus (Jeremy Bopp)
  2022-09-08  8:56 ` [ruby-core:109846] " nobu (Nobuyoshi Nakada)
  2022-09-10 21:46 ` [ruby-core:109880] " javanthropus (Jeremy Bopp)
  2 siblings, 0 replies; 4+ messages in thread
From: javanthropus (Jeremy Bopp) @ 2022-09-04 23:13 UTC (permalink / raw)
  To: ruby-core

Issue #18880 has been updated by javanthropus (Jeremy Bopp).


I'm interested in submitting a patch for this, but which behavior is considered correct?

----------------------------------------
Bug #18880: IO#sysread on Windows does not validate arguments
https://bugs.ruby-lang.org/issues/18880#change-99080

* Author: javanthropus (Jeremy Bopp)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
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.

``` ruby
r, w = IO.pipe
r.sysread(-1)
```

This raises `ArgumentError` on non-Windows and `Errno::EINVAL` on Windows.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:109846] [Ruby master Bug#18880] IO#sysread on Windows does not validate arguments
  2022-06-26 16:26 [ruby-core:109054] [Ruby master Bug#18880] IO#sysread on Windows does not validate arguments javanthropus (Jeremy Bopp)
  2022-09-04 23:13 ` [ruby-core:109843] " javanthropus (Jeremy Bopp)
@ 2022-09-08  8:56 ` nobu (Nobuyoshi Nakada)
  2022-09-10 21:46 ` [ruby-core:109880] " javanthropus (Jeremy Bopp)
  2 siblings, 0 replies; 4+ messages in thread
From: nobu (Nobuyoshi Nakada) @ 2022-09-08  8:56 UTC (permalink / raw)
  To: ruby-core

Issue #18880 has been updated by nobu (Nobuyoshi Nakada).


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.

----------------------------------------
Bug #18880: IO#sysread on Windows does not validate arguments
https://bugs.ruby-lang.org/issues/18880#change-99083

* Author: javanthropus (Jeremy Bopp)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
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.

``` ruby
r, w = IO.pipe
r.sysread(-1)
```

This raises `ArgumentError` on non-Windows and `Errno::EINVAL` on Windows.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:109880] [Ruby master Bug#18880] IO#sysread on Windows does not validate arguments
  2022-06-26 16:26 [ruby-core:109054] [Ruby master Bug#18880] IO#sysread on Windows does not validate arguments javanthropus (Jeremy Bopp)
  2022-09-04 23:13 ` [ruby-core:109843] " javanthropus (Jeremy Bopp)
  2022-09-08  8:56 ` [ruby-core:109846] " nobu (Nobuyoshi Nakada)
@ 2022-09-10 21:46 ` javanthropus (Jeremy Bopp)
  2 siblings, 0 replies; 4+ messages in thread
From: javanthropus (Jeremy Bopp) @ 2022-09-10 21:46 UTC (permalink / raw)
  To: ruby-core

Issue #18880 has been updated by javanthropus (Jeremy Bopp).


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.

----------------------------------------
Bug #18880: IO#sysread on Windows does not validate arguments
https://bugs.ruby-lang.org/issues/18880#change-99121

* Author: javanthropus (Jeremy Bopp)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
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.

``` ruby
r, w = IO.pipe
r.sysread(-1)
```

This raises `ArgumentError` on non-Windows and `Errno::EINVAL` on Windows.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-10 21:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-26 16:26 [ruby-core:109054] [Ruby master Bug#18880] IO#sysread on Windows does not validate arguments javanthropus (Jeremy Bopp)
2022-09-04 23:13 ` [ruby-core:109843] " javanthropus (Jeremy Bopp)
2022-09-08  8:56 ` [ruby-core:109846] " nobu (Nobuyoshi Nakada)
2022-09-10 21:46 ` [ruby-core:109880] " javanthropus (Jeremy Bopp)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).