From: nobu@... Date: 2021-03-07T02:20:58+00:00 Subject: [ruby-core:102766] [Ruby master Bug#17675] StringIO#each_byte doesn't check for readabilty while iterating 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/ Unsubscribe: