[Open] un-infection in StringIO#write

Issue #9769 has been reported by 宗介 相良.


Bug #9769: un-infection in StringIO#write

  • Author: 宗介 相良
  • Status: Open
  • Priority: Normal
  • Assignee:
  • Category:
  • Target version:
  • ruby -v: ruby 2.1.1p76 (2014-02-24 revision 45161) [amd64-freebsd10]
  • Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN

StringIO#write において、汚染された文字列を与えても汚染状態が伝播しません。

  • 文字列の拡張を伴わない書き込み (こちらは伝播する)

$ ruby -r stringio -e ‘str = “abcdefg”; sio = StringIO.new(str); sio <<
“hijklmn”.taint; p str: str.tainted?, sio: sio.tainted?’
{:str=>true, :sio=>false}

  • 文字列の拡張を伴う書き込み (こちらが伝播しない)

$ ruby -r stringio -e ‘str = “abcdefg”; sio = StringIO.new(str, “ab”);
sio << “hijklmn”.taint; p str: str.tainted?, sio: sio.tainted?’
{:str=>false, :sio=>false}

内部文字列オブジェクトに伝播されたほうが好ましいと思います。

確認した限りでは 1.9.3、2.0.0、2.1.1 の挙動が同じとなっています。

添付いたしましたパッチの適用で、与えられた文字列の汚染状態を伝播するようになります。

$ ruby -r stringio -e ‘str = “abcdefg”; sio = StringIO.new(str); sio <<
“hijklmn”.taint; p str: str.tainted?, sio: sio.tainted?’
{:str=>true, :sio=>false}

$ ruby -r stringio -e ‘str = “abcdefg”; sio = StringIO.new(str, “ab”);
sio << “hijklmn”.taint; p str: str.tainted?, sio: sio.tainted?’
{:str=>true, :sio=>false}

よろしくお願いします。

—Files--------------------------------
stringio_infect.patch (485 Bytes)