Project

General

Profile

Actions

Bug #3548

closed

Infinite loop in rb_str_conv_enc_opts

Bug #3548: Infinite loop in rb_str_conv_enc_opts

Added by bwbuchanan (Brian Buchanan) over 15 years ago. Updated over 14 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-07-07 trunk 28569) [x86_64-darwin10.4.0]
Backport:
[ruby-core:31107]

Description

=begin
To reproduce:

require 'stringio'
StringIO.new(''.force_encoding('ISO-2022-JP')) << ''

This will loop forever, blocking the interpreter and requiring a "kill -9" to terminate ruby. The problem is that rb_str_conv_enc_opts does not expect rb_econv_convert() to return econv_destination_buffer_full when the input string length is 0. It attempts to expand the destination buffer by doubling its allocation, which will never be successful when the initial allocation was zero.

The attached patch fixes the problem in rb_str_conv_enc_opts(). I suspect that the ISO-2022-JP encoder should also not be returning econv_destination_buffer_full when processing an empty string.
=end


Files

string.c.patch (379 Bytes) string.c.patch bwbuchanan (Brian Buchanan), 07/08/2010 02:22 AM

Updated by shyouhei (Shyouhei Urabe) over 15 years ago Actions #1

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to naruse (Yui NARUSE)
  • Priority changed from 5 to Normal

=begin

=end

Updated by naruse (Yui NARUSE) over 15 years ago Actions #2

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r28577.
Brian, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Updated by naruse (Yui NARUSE) over 15 years ago Actions #3

=begin
Thank you for a patch.

I suspect that the ISO-2022-JP encoder should also not be returning econv_destination_buffer_full when processing an empty string.
ISO-2022-JP source string may outputs escape sequence, so converter needs buffer even if source is empty.
=end

Actions

Also available in: PDF Atom