summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-31 23:00:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-31 23:00:48 +0000
commitaa8cc01aa398d231c9839bc24b7b138f2c75952f (patch)
tree729f50a906bf36c3a714689104376b35e535451d
parent488f478d24019de88aa96944a0b91987ced37e12 (diff)
zlib.c: check EOF
* ext/zlib/zlib.c (gzfile_read, gzfile_read_all, gzfile_getc), (gzreader_gets): check EOF. [ruby-core:55220] [Bug #8467] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog78
-rw-r--r--ext/zlib/zlib.c6
-rw-r--r--test/zlib/test_zlib.rb6
3 files changed, 18 insertions, 72 deletions
diff --git a/ChangeLog b/ChangeLog
index c8bb461155d..8b1462975c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,48 +1,12 @@
-Sat Jun 1 07:32:15 2013 Tanaka Akira <akr@fsij.org>
+Sat Jun 1 08:00:46 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * bignum.c: Use BDIGIT type for hbase.
+ * ext/zlib/zlib.c (gzfile_read, gzfile_read_all, gzfile_getc),
+ (gzreader_gets): check EOF. [ruby-core:55220] [Bug #8467]
-Sat Jun 1 02:37:35 2013 NARUSE, Yui <naruse@ruby-lang.org>
+Sat Jun 1 08:00:06 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/socket/option.c (sockopt_s_byte): constructor of the sockopt
- whose value's is byte.
-
- * ext/socket/option.c (sockopt_byte): getter for above.
-
- * ext/socket/option.c (inspect_byte): inspect for above.
-
- * ext/socket/option.c (sockopt_s_ip_multicast_loop): constructor of
- the sockopt whose optname is IP_MULTICAST_LOOP.
-
- * ext/socket/option.c (sockopt_ip_multicast_loop): getter for above.
-
- * ext/socket/option.c (sockopt_s_ip_multicast_ttl): constructor of
- the sockopt whose optname is IP_MULTICAST_TTL.
-
- * ext/socket/option.c (sockopt_ip_multicast_ttl): getter for above.
-
- * ext/socket/option.c (sockopt_inspect): use above.
-
-Sat Jun 01 01:50:00 2013 Kenta Murata <mrkn@mrkn.jp>
-
- * ext/bigdecimal/bigdecimal.c (BigDecimal_power): use rb_dbl2big
- to convert a double value to a Bignum.
-
-Sat Jun 1 00:19:50 2013 Tanaka Akira <akr@fsij.org>
-
- * bignum.c (calc_hbase): Make hbase the maximum power of base
- representable in BDIGIT.
-
-Fri May 31 23:56:13 2013 Tanaka Akira <akr@fsij.org>
-
- * bignum.c (calc_hbase): Extracted from rb_big2str0.
-
-Fri May 31 23:22:24 2013 Tanaka Akira <akr@fsij.org>
-
- * bignum.c: Don't hard code SIZEOF_BDIGITS for log_base(hbase).
- (big2str_orig): hbase_numdigits argument added.
- (big2str_karatsuba): Ditto.
- (rb_big2str0): Calculate hbase_numdigits.
+ * ext/zlib/zlib.c (gzfile_read, gzfile_read_all, gzfile_getc),
+ (gzreader_gets): check EOF. [ruby-core:55220] [Bug #8467]
Fri May 31 17:57:21 2013 Zachary Scott <zachary@zacharyscott.net>
@@ -80,34 +44,6 @@ Fri May 31 11:58:24 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_method.c (set_visibility): extract from rb_mod_public(),
rb_mod_protected() and rb_mod_private().
-Thu May 30 19:47:42 2013 Yusuke Endoh <mame@tsg.ne.jp>
-
- * vm_insnhelper.c (vm_callee_setup_keyword_arg,
- vm_callee_setup_arg_complex): consider a hash argument for keyword
- only when the number of arguments is more than the expected
- mandatory parameters. [ruby-core:53199] [ruby-trunk - Bug #8040]
-
- * test/ruby/test_keyword.rb: update a test for above.
-
-Thu May 30 17:55:04 2013 Zachary Scott <zachary@zacharyscott.net>
-
- * process.c: RDoc on Process.spawn
-
-Thu May 30 00:08:14 2013 Koichi Sasada <ko1@atdot.net>
-
- * gc.c (gc_profile_enable): rest_sweep() to finish last GC.
- Profiling record is allocated at first of marking phase.
- Enable at lazy sweeping may cause an error (SEGV).
-
-Wed May 29 10:33:27 2013 Koichi Sasada <ko1@atdot.net>
-
- * hash.c: fix WB bug.
- (1) Hash's key also needs WB.
- (2) callback parameter *key and *value of st_update() is not a
- storage of st_table itself (only local variable). So that
- OBJ_WRITE() is not suitable, especially for `!existing'.
- OBJ_WRITTEN() is used instead of OBJ_WRITE().
-
Tue May 28 12:31:21 2013 Koichi Sasada <ko1@atdot.net>
* ext/objspace/object_tracing.c: fix a bug reported at
@@ -1530,7 +1466,7 @@ Sat May 4 04:13:27 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Fri May 3 19:32:13 2013 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
- * lib/cgi/util.rb: All class methods modulized.
+ * lib/cgi/util.rb: All class methods moduleized.
We can use these methods like a function when "include CGI::Util".
[Feature #8354]
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index db153e36946..918bad6b7dd 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -2709,7 +2709,7 @@ gzfile_read(struct gzfile *gz, long len)
if (len == 0) return rb_str_new(0, 0);
if (len < 0) return Qnil;
dst = zstream_shift_buffer(&gz->z, len);
- gzfile_calc_crc(gz, dst);
+ if (!NIL_P(dst)) gzfile_calc_crc(gz, dst);
return dst;
}
@@ -2772,6 +2772,7 @@ gzfile_read_all(struct gzfile *gz)
}
dst = zstream_detach_buffer(&gz->z);
+ if (NIL_P(dst)) return dst;
gzfile_calc_crc(gz, dst);
OBJ_TAINT(dst);
return gzfile_newstr(gz, dst);
@@ -2818,6 +2819,7 @@ gzfile_getc(struct gzfile *gz)
buf = gz->z.buf;
len = rb_enc_mbclen(RSTRING_PTR(buf), RSTRING_END(buf), gz->enc);
dst = gzfile_read(gz, len);
+ if (NIL_P(dst)) return dst;
return gzfile_newstr(gz, dst);
}
}
@@ -4039,6 +4041,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
n = limit;
}
dst = zstream_shift_buffer(&gz->z, n);
+ if (NIL_P(dst)) return dst;
gzfile_calc_crc(gz, dst);
dst = gzfile_newstr(gz, dst);
}
@@ -4100,6 +4103,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
gz->lineno++;
dst = gzfile_read(gz, n);
+ if (NIL_P(dst)) return dst;
if (rspara) {
gzreader_skip_linebreaks(gz);
}
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb
index 6e21f6d2713..81d440f8468 100644
--- a/test/zlib/test_zlib.rb
+++ b/test/zlib/test_zlib.rb
@@ -685,6 +685,7 @@ if defined? Zlib
end
def test_rewind
+ bug8467 = '[ruby-core:55220] [Bug #8467]'
Tempfile.create("test_zlib_gzip_reader_rewind") {|t|
t.close
Zlib::GzipWriter.open(t.path) {|gz| gz.print("foo") }
@@ -694,6 +695,11 @@ if defined? Zlib
f.rewind
assert_equal("foo", f.read)
end
+ open(t.path, "rb") do |f|
+ gz = Zlib::GzipReader.new(f)
+ gz.rewind
+ assert_equal(["foo"], gz.to_a, bug8467)
+ end
}
end