Ruby Issue Tracking System: Issueshttps://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112021-03-07T01:48:29ZRuby Issue Tracking System
Redmine Ruby master - Bug #17675 (Closed): StringIO#each_byte doesn't check for readabilty while iteratinghttps://redmine.ruby-lang.org/issues/176752021-03-07T01:48:29Zwyhaines (Kirk Haines)wyhaines@gmail.com
<p>Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: IO#each will segfault when if file is closed inside an `each_byte` block (Closed)" href="https://redmine.ruby-lang.org/issues/17661">#17661</a> is a failure to check readability on <code>each_byte</code> of an IO, causing a segmentation fault.</p>
<p>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.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s2">"stringio"</span>
<span class="n">strio</span> <span class="o">=</span> <span class="no">StringIO</span><span class="p">.</span><span class="nf">new</span>
<span class="n">strio</span><span class="p">.</span><span class="nf">each_byte</span> <span class="k">do</span> <span class="o">|</span><span class="n">byte</span><span class="o">|</span>
<span class="nb">puts</span> <span class="n">byte</span>
<span class="n">strio</span><span class="p">.</span><span class="nf">close</span>
<span class="k">end</span>
</code></pre>
<p>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.</p>
<p>I have a PR for this which I will submit on Github and link to.<br>
The PR simply inserts an appropriate check into the loop for <code>each_byte</code>.</p> Backport186 - Backport #1975 (Closed): Backport Dir.mktmpdirhttps://redmine.ruby-lang.org/issues/19752009-08-21T21:21:31Zwyhaines (Kirk Haines)wyhaines@gmail.com
<p>=begin<br>
Dir.mktmpdir exists in 1.8 HEAD and 1.8.7, and is used in the test suite for Backport <a class="issue tracker-4 status-5 priority-4 priority-default closed" title="Backport: wrong result of File.extname for path contains a space just before the extension (Closed)" href="https://redmine.ruby-lang.org/issues/1168">#1168</a>, so it needs to be backported to 1.8.6 to facilitate use of the existing test suite.<br>
=end</p> Backport186 - Backport #1589 (Closed): Backport BigDecimal fixeshttps://redmine.ruby-lang.org/issues/15892009-06-09T03:33:38Zwyhaines (Kirk Haines)wyhaines@gmail.com
<p>=begin<br>
Backport fixes in bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: BigDecimal が Segmentation fault で落ることがある (Closed)" href="https://redmine.ruby-lang.org/issues/794">#794</a> (<a href="http://redmine.ruby-lang.org/issues/show/794" class="external">http://redmine.ruby-lang.org/issues/show/794</a>) which eliminate some BigDecimal bugs.<br>
=end</p>