ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:102764] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating
@ 2021-03-07  1:48 wyhaines
  2021-03-07  2:00 ` [ruby-core:102765] " wyhaines
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: wyhaines @ 2021-03-07  1:48 UTC (permalink / raw
  To: ruby-core

Issue #17675 has been reported by wyhaines (Kirk Haines).

----------------------------------------
Bug #17675: StringIO#each_byte doesn't check for readabilty while iterating
https://bugs.ruby-lang.org/issues/17675

* Author: wyhaines (Kirk Haines)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Bug #17661 is a failure to check readability on `each_byte` of an IO, causing a segmentation fault.

StringIO has an independent, but related implementation, and it shares the same flaw in its implementation, where it fails to check for the readability of the StringIO object while iterating over the bytes. Unlike IO, this does not result in a segmentation fault. It does, however, allow the continued reading from an object that has been closed.

``` ruby
require "stringio"

strio = StringIO.new
strio.each_byte do |byte|
  puts byte
  strio.close
end
```

That code should print the first byte, and then throw an IOError, but instead, it iterates through the entire data buffer for the object, calling the block for each byte, without ever raising an exception.

I have a PR for this which I will submit on Github and link to.
The PR simply inserts an appropriate check into the loop for `each_byte`.



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

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

* [ruby-core:102765] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating
  2021-03-07  1:48 [ruby-core:102764] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating wyhaines
@ 2021-03-07  2:00 ` wyhaines
  2021-03-07  2:20 ` [ruby-core:102766] " nobu
  2021-11-22  1:52 ` [ruby-core:106196] " nagachika (Tomoyuki Chikanaga)
  2 siblings, 0 replies; 4+ messages in thread
From: wyhaines @ 2021-03-07  2:00 UTC (permalink / raw
  To: ruby-core

Issue #17675 has been updated by wyhaines (Kirk Haines).


The PR is:

https://github.com/ruby/ruby/pull/4245

----------------------------------------
Bug #17675: StringIO#each_byte doesn't check for readabilty while iterating
https://bugs.ruby-lang.org/issues/17675#change-90784

* Author: wyhaines (Kirk Haines)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Bug #17661 is a failure to check readability on `each_byte` of an IO, causing a segmentation fault.

StringIO has an independent, but related implementation, and it shares the same flaw in its implementation, where it fails to check for the readability of the StringIO object while iterating over the bytes. Unlike IO, this does not result in a segmentation fault. It does, however, allow the continued reading from an object that has been closed.

``` ruby
require "stringio"

strio = StringIO.new
strio.each_byte do |byte|
  puts byte
  strio.close
end
```

That code should print the first byte, and then throw an IOError, but instead, it iterates through the entire data buffer for the object, calling the block for each byte, without ever raising an exception.

I have a PR for this which I will submit on Github and link to.
The PR simply inserts an appropriate check into the loop for `each_byte`.



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

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

* [ruby-core:102766] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating
  2021-03-07  1:48 [ruby-core:102764] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating wyhaines
  2021-03-07  2:00 ` [ruby-core:102765] " wyhaines
@ 2021-03-07  2:20 ` nobu
  2021-11-22  1:52 ` [ruby-core:106196] " nagachika (Tomoyuki Chikanaga)
  2 siblings, 0 replies; 4+ messages in thread
From: nobu @ 2021-03-07  2:20 UTC (permalink / raw
  To: ruby-core

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


Please submit to https://github.com/ruby/stringio

----------------------------------------
Bug #17675: StringIO#each_byte doesn't check for readabilty while iterating
https://bugs.ruby-lang.org/issues/17675#change-90785

* Author: wyhaines (Kirk Haines)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Bug #17661 is a failure to check readability on `each_byte` of an IO, causing a segmentation fault.

StringIO has an independent, but related implementation, and it shares the same flaw in its implementation, where it fails to check for the readability of the StringIO object while iterating over the bytes. Unlike IO, this does not result in a segmentation fault. It does, however, allow the continued reading from an object that has been closed.

``` ruby
require "stringio"

strio = StringIO.new
strio.each_byte do |byte|
  puts byte
  strio.close
end
```

That code should print the first byte, and then throw an IOError, but instead, it iterates through the entire data buffer for the object, calling the block for each byte, without ever raising an exception.

I have a PR for this which I will submit on Github and link to.
The PR simply inserts an appropriate check into the loop for `each_byte`.



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

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

* [ruby-core:106196] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating
  2021-03-07  1:48 [ruby-core:102764] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating wyhaines
  2021-03-07  2:00 ` [ruby-core:102765] " wyhaines
  2021-03-07  2:20 ` [ruby-core:102766] " nobu
@ 2021-11-22  1:52 ` nagachika (Tomoyuki Chikanaga)
  2 siblings, 0 replies; 4+ messages in thread
From: nagachika (Tomoyuki Chikanaga) @ 2021-11-22  1:52 UTC (permalink / raw
  To: ruby-core

Issue #17675 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN to 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: DONE

Backported into ruby_3_0 at e6fced73e55dda487f026c929d97542cf1832252. Thank you hsbt san.

----------------------------------------
Bug #17675: StringIO#each_byte doesn't check for readabilty while iterating
https://bugs.ruby-lang.org/issues/17675#change-94800

* Author: wyhaines (Kirk Haines)
* Status: Closed
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: DONE
----------------------------------------
Bug #17661 is a failure to check readability on `each_byte` of an IO, causing a segmentation fault.

StringIO has an independent, but related implementation, and it shares the same flaw in its implementation, where it fails to check for the readability of the StringIO object while iterating over the bytes. Unlike IO, this does not result in a segmentation fault. It does, however, allow the continued reading from an object that has been closed.

``` ruby
require "stringio"

strio = StringIO.new
strio.each_byte do |byte|
  puts byte
  strio.close
end
```

That code should print the first byte, and then throw an IOError, but instead, it iterates through the entire data buffer for the object, calling the block for each byte, without ever raising an exception.

I have a PR for this which I will submit on Github and link to.
The PR simply inserts an appropriate check into the loop for `each_byte`.



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

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

end of thread, other threads:[~2021-11-22  1:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-07  1:48 [ruby-core:102764] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating wyhaines
2021-03-07  2:00 ` [ruby-core:102765] " wyhaines
2021-03-07  2:20 ` [ruby-core:102766] " nobu
2021-11-22  1:52 ` [ruby-core:106196] " nagachika (Tomoyuki Chikanaga)

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).