[前][次][番号順一覧][スレッド一覧]

ruby-changes:28962

From: nobu <ko1@a...>
Date: Sat, 1 Jun 2013 08:04:16 +0900 (JST)
Subject: [ruby-changes:28962] nobu:r41014 (trunk): zlib.c: check EOF

nobu	2013-06-01 08:00:48 +0900 (Sat, 01 Jun 2013)

  New Revision: 41014

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41014

  Log:
    zlib.c: check EOF
    
    * ext/zlib/zlib.c (gzfile_read, gzfile_read_all, gzfile_getc),
      (gzreader_gets): check EOF.  [ruby-core:55220] [Bug #8467]

  Modified files:
    trunk/ChangeLog
    trunk/ext/zlib/zlib.c
    trunk/test/zlib/test_zlib.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41013)
+++ ChangeLog	(revision 41014)
@@ -1,48 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Sat Jun  1 07:32:15 2013  Tanaka Akira  <akr@f...>
+Sat Jun  1 08:00:46 2013  Nobuyoshi Nakada  <nobu@r...>
 
-	* 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@r...>
+Sat Jun  1 08:00:06 2013  Nobuyoshi Nakada  <nobu@r...>
 
-	* 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@m...>
-
-	* 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@f...>
-
-	* bignum.c (calc_hbase): Make hbase the maximum power of base
-	  representable in BDIGIT.
-
-Fri May 31 23:56:13 2013  Tanaka Akira  <akr@f...>
-
-	* bignum.c (calc_hbase): Extracted from rb_big2str0.
-
-Fri May 31 23:22:24 2013  Tanaka Akira  <akr@f...>
-
-	* 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@z...>
 
@@ -80,34 +44,6 @@ Fri May 31 11:58:24 2013  Nobuyoshi Naka https://github.com/ruby/ruby/blob/trunk/ChangeLog#L44
 	* 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@t...>
-
-	* 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@z...>
-
-	* process.c: RDoc on Process.spawn
-
-Thu May 30 00:08:14 2013  Koichi Sasada  <ko1@a...>
-
-	* 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@a...>
-
-	* 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@a...>
 
 	* ext/objspace/object_tracing.c: fix a bug reported at
@@ -1530,7 +1466,7 @@ Sat May  4 04:13:27 2013  KOSAKI Motohir https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1466
 
 Fri May  3 19:32:13 2013  Takeyuki FUJIOKA  <xibbar@r...>
 
-	* 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]
 
Index: ext/zlib/zlib.c
===================================================================
--- ext/zlib/zlib.c	(revision 41013)
+++ ext/zlib/zlib.c	(revision 41014)
@@ -2709,7 +2709,7 @@ gzfile_read(struct gzfile *gz, long len) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L2709
     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) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L2772
     }
 
     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) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L2819
 	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, VAL https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L4041
 		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, VAL https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L4103
 
     gz->lineno++;
     dst = gzfile_read(gz, n);
+    if (NIL_P(dst)) return dst;
     if (rspara) {
 	gzreader_skip_linebreaks(gz);
     }
Index: test/zlib/test_zlib.rb
===================================================================
--- test/zlib/test_zlib.rb	(revision 41013)
+++ test/zlib/test_zlib.rb	(revision 41014)
@@ -685,6 +685,7 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L685
     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 https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L695
           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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]