1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/zlib/zlib.c (zstream_run): Fix handling of deflate streams that

need a dictionary but are being decompressed by Zlib::Inflate.inflate
  (which has no option to set a dictionary).  Now Zlib::NeedDict is
  raised instead of crashing.  [ruby-trunk - Bug #8829]
* test/zlib/test_zlib.rb (TestZlibInflate):  Test for the above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-08-28 20:36:21 +00:00
parent c94b0e8568
commit 9f2f1fcbc8
3 changed files with 21 additions and 5 deletions

View file

@ -1,3 +1,11 @@
Thu Aug 29 05:35:58 2013 Eric Hodel <drbrain@segment7.net>
* ext/zlib/zlib.c (zstream_run): Fix handling of deflate streams that
need a dictionary but are being decompressed by Zlib::Inflate.inflate
(which has no option to set a dictionary). Now Zlib::NeedDict is
raised instead of crashing. [ruby-trunk - Bug #8829]
* test/zlib/test_zlib.rb (TestZlibInflate): Test for the above.
Thu Aug 29 02:40:45 2013 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/scalar_scanner.rb: invalid floats should be

View file

@ -1074,11 +1074,13 @@ loop:
}
if (err == Z_NEED_DICT) {
VALUE self = (VALUE)z->stream.opaque;
VALUE dicts = rb_ivar_get(self, id_dictionaries);
VALUE dict = rb_hash_aref(dicts, rb_uint2inum(z->stream.adler));
if (!NIL_P(dict)) {
rb_inflate_set_dictionary(self, dict);
goto loop;
if (self) {
VALUE dicts = rb_ivar_get(self, id_dictionaries);
VALUE dict = rb_hash_aref(dicts, rb_uint2inum(z->stream.adler));
if (!NIL_P(dict)) {
rb_inflate_set_dictionary(self, dict);
goto loop;
}
}
}
raise_zlib_error(err, z->stream.msg);

View file

@ -232,6 +232,12 @@ if defined? Zlib
end
class TestZlibInflate < Test::Unit::TestCase
def test_class_inflate_dictionary
assert_raises(Zlib::NeedDict) do
Zlib::Inflate.inflate([0x08,0x3C,0x0,0x0,0x0,0x0].pack("c*"))
end
end
def test_initialize
assert_raise(Zlib::StreamError) { Zlib::Inflate.new(-1) }