ruby-changes:47416
From: usa <ko1@a...>
Date: Wed, 9 Aug 2017 17:08:07 +0900 (JST)
Subject: [ruby-changes:47416] usa:r59532 (ruby_2_3): merge revision(s) 59333, 59337: [Backport #13616]
usa 2017-08-09 17:08:01 +0900 (Wed, 09 Aug 2017) New Revision: 59532 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59532 Log: merge revision(s) 59333,59337: [Backport #13616] Zlib::GzipReader#pos underflows after calling #ungetbyte or #ungetc at start of file [Bug #13616] patched by Andrew Haines <andrew@h...> [ruby-core:81488] zlib.c: fix unnormalized Fixnum * ext/zlib/zlib.c (rb_gzfile_total_out): cast to long not to result in an unsigned long to normalized to Fixnum on LLP64 platforms. [ruby-core:81488] Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ext/zlib/zlib.c branches/ruby_2_3/test/zlib/test_zlib.rb branches/ruby_2_3/version.h Index: ruby_2_3/test/zlib/test_zlib.rb =================================================================== --- ruby_2_3/test/zlib/test_zlib.rb (revision 59531) +++ ruby_2_3/test/zlib/test_zlib.rb (revision 59532) @@ -650,6 +650,18 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/zlib/test_zlib.rb#L650 } end + def test_ungetc_at_start_of_file + s = "".dup + w = Zlib::GzipWriter.new(StringIO.new(s)) + w << "abc" + w.close + r = Zlib::GzipReader.new(StringIO.new(s)) + + r.ungetc ?! + + assert_equal(-1, r.pos, "[ruby-core:81488][Bug #13616]") + end + def test_open Tempfile.create("test_zlib_gzip_reader_open") {|t| t.close Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 59531) +++ ruby_2_3/version.h (revision 59532) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.5" #define RUBY_RELEASE_DATE "2017-08-09" -#define RUBY_PATCHLEVEL 344 +#define RUBY_PATCHLEVEL 345 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_3/ext/zlib/zlib.c =================================================================== --- ruby_2_3/ext/zlib/zlib.c (revision 59531) +++ ruby_2_3/ext/zlib/zlib.c (revision 59532) @@ -3407,7 +3407,14 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/zlib/zlib.c#L3407 rb_gzfile_total_out(VALUE obj) { struct gzfile *gz = get_gzfile(obj); - return rb_uint2inum(gz->z.stream.total_out - gz->z.buf_filled); + uLong total_out = gz->z.stream.total_out; + long buf_filled = gz->z.buf_filled; + + if (total_out >= (uLong)buf_filled) { + return rb_uint2inum(total_out - buf_filled); + } else { + return LONG2FIX(-(buf_filled - (long)total_out)); + } } /* Index: ruby_2_3 =================================================================== --- ruby_2_3 (revision 59531) +++ ruby_2_3 (revision 59532) Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r59333 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/