8000 zlib.c: check EOF · plusplus/ruby@aa8cc01 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa8cc01

Browse files
committed
zlib.c: check EOF
* ext/zlib/zlib.c (gzfile_read, gzfile_read_all, gzfile_getc), (gzreader_gets): check EOF. [ruby-core:55220] [Bug ruby#8467] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 488f478 commit aa8cc01

File tree

3 files changed

+18
-72
lines changed

3 files changed

+18
-72
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,12 @@
1-
Sat Jun 1 07:32:15 2013 Tanaka Akira <akr@fsij.org>
1+
Sat Jun 1 08:00:46 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
22

3-
* bignum.c: Use BDIGIT type for hbase.
3+
* ext/zlib/zlib.c (gzfile_read, gzfile_read_all, gzfile_getc),
4+
(gzreader_gets): check EOF. [ruby-core:55220] [Bug #8467]
45

5-
Sat Jun 1 02:37:35 2013 NARUSE, Yui <naruse@ruby-lang.org>
6+
Sat Jun 1 08:00:06 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
67

7-
* ext/socket/option.c (sockopt_s_byte): constructor of the sockopt
8-
whose value's is byte.
9-
10-
* ext/socket/option.c (sockopt_byte): getter for above.
11-
12-
* ext/socket/option.c (inspect_byte): inspect for above.
13-
14-
* ext/socket/option.c (sockopt_s_ip_multicast_loop): constructor of
15-
the sockopt whose optname is IP_MULTICAST_LOOP.
16-
17-
* ext/socket/option.c (sockopt_ip_multicast_loop): getter for above.
18-
19-
* ext/socket/option.c (sockopt_s_ip_multicast_ttl): constructor of
20-
the sockopt whose optname is IP_MULTICAST_TTL.
21-
22-
* ext/socket/option.c (sockopt_ip_multicast_ttl): getter for above.
23-
24-
* ext/socket/option.c (sockopt_inspect): use above.
25-
26-
Sat Jun 01 01:50:00 2013 Kenta Murata <mrkn@mrkn.jp>
27-
28-
* ext/bigdecimal/bigdecimal.c (BigDecimal_power): use rb_dbl2big
29-
to convert a double value to a Bignum.
30-
31-
Sat Jun 1 00:19:50 2013 Tanaka Akira <akr@fsij.org>
32-
33-
* bignum.c (calc_hbase): Make hbase the maximum power of base
34-
representable in BDIGIT.
35-
36-
Fri May 31 23:56:13 2013 Tanaka Akira <akr@fsij.org>
37-
38-
* bignum.c (calc_hbase): Extracted from rb_big2str0.
39-
40-
Fri May 31 23:22:24 2013 Tanaka Akira <akr@fsij.org>
41-
42-
* bignum.c: Don't hard code SIZEOF_BDIGITS for log_base(hbase).
43-
(big2str_orig): hbase_numdigits argument added.
44-
(big2str_karatsuba): Ditto.
45-
(rb_big2str0): Calculate hbase_numdigits.
8+
* ext/zlib/zlib.c (gzfile_read, gzfile_read_all, gzfile_getc),
9+
(gzreader_gets): check EOF. [ruby-core:55220] [Bug #8467]
4610

4711
Fri May 31 17:57:21 2013 Zachary Scott <zachary@zacharyscott.net>
4812

@@ -80,34 +44,6 @@ Fri May 31 11:58:24 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
8044
* vm_method.c (set_visibility): extract from rb_mod_public(),
8145
rb_mod_protected() and rb_mod_private().
8246

83-
Thu May 30 19:47:42 2013 Yusuke Endoh <mame@tsg.ne.jp>
84-
85-
* vm_insnhelper.c (vm_callee_setup_keyword_arg,
86-
vm_callee_setup_arg_complex): consider a hash argument for keyword
87-
only when the number of arguments is more than the expected
88-
mandatory parameters. [ruby-core:53199] [ruby-trunk - Bug #8040]
89-
90-
* test/ruby/test_keyword.rb: update a test for above.
91-
92-
Thu May 30 17:55:04 2013 Zachary Scott <zachary@zacharyscott.net>
93-
94-
* process.c: RDoc on Process.spawn
95-
96-
Thu May 30 00:08:14 2013 Koichi Sasada <ko1@atdot.net>
97-
98-
* gc.c (gc_profile_enable): rest_sweep() to finish last GC.
99-
Profiling record is allocated at first of marking phase.
100-
Enable at lazy sweeping may cause an error (SEGV).
101-
102-
Wed May 29 10:33:27 2013 Koichi Sasada <ko1@atdot.net>
103-
104-
* hash.c: fix WB bug.
105-
(1) Hash's key also needs WB.
106-
(2) callback parameter *key and *value of st_update() is not a
107-
storage of st_table itself (only local variable). So that
108-
OBJ_WRITE() is not suitable, especially for `!existing'.
109-
OBJ_WRITTEN() is used instead of OBJ_WRITE().
110-
11147
Tue May 28 12:31:21 2013 Koichi Sasada <ko1@atdot.net>
11248

11349
* 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>
15301466

15311467
Fri May 3 19:32:13 2013 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
15321468

1533-
* lib/cgi/util.rb: All class methods modulized.
1469+
* lib/cgi/util.rb: All class methods moduleized.
15341470
We can use these methods like a function when "include CGI::Util".
15351471
[Feature #8354]
15361472

ext/zlib/zlib.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,7 @@ gzfile_read(struct gzfile *gz, long len)
27092709
if (len == 0) return rb_str_new(0, 0);
27102710
if (len < 0) return Qnil;
27112711
dst = zstream_shift_buffer(&gz->z, len);
2712-
gzfile_calc_crc(gz, dst);
2712+
if (!NIL_P(dst)) gzfile_calc_crc(gz, dst);
27132713
return dst;
27142714
}
27152715

@@ -2772,6 +2772,7 @@ gzfile_read_all(struct gzfile *gz)
27722772
}
27732773

27742774
dst = zstream_detach_buffer(&gz->z);
2775+
if (NIL_P(dst)) return dst;
27752776
gzfile_calc_crc(gz, dst);
27762777
OBJ_TAINT(dst);
27772778
return gzfile_newstr(gz, dst);
@@ -2818,6 +2819,7 @@ gzfile_getc(struct gzfile *gz)
28182819
buf = gz->z.buf;
28192820
len = rb_enc_mbclen(RSTRING_PTR(buf), RSTRING_END(buf), gz->enc);
28202821
dst = gzfile_read(gz, len);
2822+
if (NIL_P(dst)) return dst;
28212823
return gzfile_newstr(gz, dst);
28222824
}
28232825
}
@@ -4039,6 +4041,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
40394041
n = limit;
40404042
}
40414043
dst = zstream_shift_buffer(&gz->z, n);
4044+
if (NIL_P(dst)) return dst;
4042 102AB 4045
gzfile_calc_crc(gz, dst);
40434046
dst = gzfile_newstr(gz, dst);
40444047
}
@@ -4100,6 +4103,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
41004103

41014104
gz->lineno++;
41024105
dst = gzfile_read(gz, n);
4106+
if (NIL_P(dst)) return dst;
41034107
if (rspara) {
41044108
gzreader_skip_linebreaks(gz);
41054109
}

test/zlib/test_zlib.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ def test_open
685685
end
686686

687687
def test_rewind
688+
bug8467 = '[ruby-core:55220] [Bug #8467]'
688689
Tempfile.create("test_zlib_gzip_reader_rewind") {|t|
689690
t.close
690691
Zlib::GzipWriter.open(t.path) {|gz| gz.print("foo") }
@@ -694,6 +695,11 @@ def test_rewind
694695
f.rewind
695696
assert_equal("foo", f.read)
696697
end
698+
open(t.path, "rb") do |f|
699+
gz = Zlib::GzipReader.new(f)
700+
gz.rewind
701+
assert_equal(["foo"], gz.to_a, bug8467)
702+
end
697703
}
698704
end
699705

0 commit comments

Comments
 (0)
0