Граф коммитов

68 Коммитов

Автор SHA1 Сообщение Дата
Alan Wu 0aaa15f636 [ruby/zlib] Fix setting mtime to zero in GzipWriter
Before this change, it was not possible to write out zero for the
timestamp part of a Gzip file's header, as calling GzipWriter#mtime with
zero was ignored.

Judging from the docs for `GzipWriter#mtime=`, it should be possible to
indicate that no timestamp is available by calling the method with zero.

https://github.com/ruby/zlib/commit/310be39cac
2019-10-31 22:23:58 +09:00
Jeremy Evans 290903dba0
[ruby/zlib] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.

https://github.com/ruby/zlib/commit/21711ed0ce
2019-10-31 15:34:01 +09:00
Nobuyoshi Nakada 1cce430324
Suppress deflateParams() warnings 2019-07-24 22:07:10 +09:00
normal cc9b57a2b4 zlib (gzfile_write_raw): do not resize string after .write call
Apparently, a component of Rails implements a buffering .write
method which keeps the String buffer around and makes it unsafe
for us to clear it after calling .write.

This caused Rack::Deflater to give empty results when enabled.

Fortunately, per r61631 / a55abcc0ca,
this misguided optimization was only worth a small (0.5MB) savings
and we still benefit from the majority of the memory savings in
that change.

Thanks to zunda for the bug report.

[ruby-core:90133] [Bug #15356]

Fixes: r61631 (commit a55abcc0ca)
       ("zlib: reduce garbage on gzip writes (deflate)")

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-07 07:09:31 +00:00
mame 7735e2da11 test/zlib/test_zlib.rb (test_path): enable the accidentally-disabled assertion
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-17 06:38:08 +00:00
nobu 585cbf6535 zlib.c: multiple arguments to write
* ext/zlib/zlib.c (rb_gzwriter_write): accepts multiple arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 07:06:12 +00:00
nobu b268da23d2 zlib.c: memory leak in gunzip
* ext/zlib/zlib.c (zlib_gunzip): clear zstream to fix memory leak.
  [ruby-core:83162] [Bug #13982]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-06 13:41:37 +00:00
naruse 7c9c2bc1dd Zlib::GzipReader#pos underflows after calling #ungetbyte or #ungetc at start of file [Bug #13616]
patched by Andrew Haines <andrew@haines.org.nz> [ruby-core:81488]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-14 09:17:55 +00:00
nobu d70e47dc6b zlib.c: no buf_filled in zstream
* ext/zlib/zlib.c (zstream): manage capacity and size of `buf`
  instead of size and separated member `buf_filled`.  reported by
  Christian Jalio (jalio) at https://hackerone.com/reports/211958

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-01 02:01:38 +00:00
kazu 026ded9384 {ext,test}/zlib: Specify frozen_string_literal: true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-07 12:49:57 +00:00
nobu 3408e9e3c3 revert r57323
StringIO.new makes the buffer IO.default_external, while
StringIO.new("".dup) makes source encoding which is defaulted to
UTF-8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-14 09:38:56 +00:00
nobu c8a4b57254 StringIO.new makes a RW buffer
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-14 02:06:22 +00:00
naruse f3d0c2729a suppress warning: attempt to close unfinished zstream; reset forced.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-20 16:02:22 +00:00
naruse ba568c0ea3 Zlib.gzip uses kwargs instead of argc [Feature #13020]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-20 16:02:21 +00:00
nobu f46a137746 zlib.c: replace with substring
* ext/zlib/zlib.c (zstream_discard_input): replace with unread
  portion substring, not modifying the input buffer directly.
  [ruby-core:78567] [Bug #13021]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-10 08:26:40 +00:00
naruse 583b6dc33c Zlib.gzip and Zlib.gunzip [Feature #13020]
Encode and Decode gzip data without creating files.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-09 22:45:39 +00:00
odaira 1ec6bb95bc * test/zlib/test_zlib.rb (test_adler32_combine, test_crc32_combine):
Skip two tests on AIX because zconf.h in zlib does not correctly
  recognize _LARGE_FILES in AIX. The problem was already reported
  to zlib, and skip these tests until it is fixed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-04 22:20:56 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
nobu ae042f21fb use assert_raise
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 02:18:44 +00:00
glass d88957abad * ext/zlib/zlib.c (rb_gzreader_external_encoding):
define GzipReader#external_encoding.
  [Bug #10900]

* test/zlib/test_zlib.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 03:43:22 +00:00
akr b6d5ce7975 * ext/zlib/zlib.c (rb_gzfile_close): Don't raise on double
close for consistent to IO#close.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 13:52:51 +00:00
akr 255955585c * io.c (rb_io_close_m): Don't raise when the IO object is closed.
[ruby-core:67444] [Feature #10718]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-15 15:26:03 +00:00
normal 3cee6a22c0 zlib: GzipReader#rewind preserves ZSTREAM_FLAG_GZFILE
* ext/zlib/zlib.c (gzfile_reset): preserve ZSTREAM_FLAG_GZFILE
  [Bug #10101]

* test/zlib/test_zlib.rb (test_rewind): test each_byte

We must preserve the ZSTREAM_FLAG_GZFILE flag to prevent
zstream_detach_buffer from:

a) returning Qnil and breaking out of the `each_byte' loop
b) yielding a large string to each_byte

Note: the test case in bug report takes a long time.  I found this
bug because I noticed the massive time descrepancy between
`each_byte' and `readbyte' loop before this patch.  With this patch,
`each_byte' and `readbyte' both take very long.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-30 23:53:28 +00:00
hsbt f6ae77d97a * test/zlib/test_zlib.rb: remove commented out code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 06:57:28 +00:00
hsbt 93156392dd * test/socket/test_addrinfo.rb: remove unused variables.
* test/socket/test_nonblock.rb: ditto.
* test/socket/test_socket.rb: ditto.
* test/socket/test_unix.rb: ditto.
* test/testunit/test_parallel.rb: ditto.
* test/webrick/test_filehandler.rb: ditto.
* test/xmlrpc/test_features.rb: ditto.
* test/zlib/test_zlib.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-18 12:05:09 +00:00
drbrain 9f2f1fcbc8 * 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
2013-08-28 20:36:21 +00:00
nobu aa8cc01aa3 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
2013-05-31 23:00:48 +00:00
akr 8f671120f1 * test/csv/test_features.rb, test/logger/test_logger.rb
test/mkmf/test_have_macro.rb, test/net/http/test_http.rb,
  test/openssl/test_config.rb, test/psych/test_encoding.rb,
  test/psych/test_exception.rb, test/psych/test_psych.rb,
  test/psych/test_tainted.rb, test/readline/test_readline.rb,
  test/rexml/test_contrib.rb, test/ruby/test_autoload.rb,
  test/ruby/test_beginendblock.rb, test/ruby/test_exception.rb,
  test/ruby/test_file.rb, test/ruby/test_io.rb,
  test/ruby/test_marshal.rb, test/ruby/test_process.rb,
  test/ruby/test_require.rb, test/ruby/test_rubyoptions.rb,
  test/syslog/test_syslog_logger.rb, test/webrick/test_httpauth.rb,
  test/zlib/test_zlib.rb: Use Tempfile.create.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-20 23:03:52 +00:00
akr 052c0e67d9 * test/ruby/test_require.rb: Remove temporally files in the tests.
* test/ruby/test_rubyoptions.rb: Ditto.

* test/logger/test_logger.rb: Ditto.

* test/psych/test_psych.rb: Ditto.

* test/readline/test_readline.rb: Ditto.

* test/syslog/test_syslog_logger.rb: Ditto.

* test/webrick/test_httpauth.rb: Ditto.

* test/zlib/test_zlib.rb: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24 02:06:32 +00:00
drbrain 3cf7d1b57e * ext/zlib/zlib.c: Added streaming support to inflate processing.
This allows zlib streams to be processed without huge memory growth.
  [Feature #6612]
* NEWS:  ditto
* ext/zlib/zlib.c (zstream_expand_buffer):  Uses rb_yield when a block
  is given for streaming support.  Refactored to use
  zstream_expand_buffer_into to remove duplicate code.
* ext/zlib/zlib.c (zstream_expand_buffer_protect):  Added wrapper
  function to pass jump state back through GVL-free section to allow
  zstream clean-up before terminating the ruby call.
* ext/zlib/zlib.c (zstream_expand_buffer_without_gvl):  Acquire GVL to
  yield processed chunk of output stream.
* ext/zlib/zlib.c (zstream_detach_buffer):  When a block is given,
  returns Qnil mid-stream and yields the output buffer at the end of
  the stream.
* test/zlib/test_zlib.rb:  Updated tests


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-10 18:28:40 +00:00
drbrain 1a853390ee * ext/zlib/zlib.c: Revert r36349. Added streaming support to inflate
processing.  rb_block_given_p() is not callable without the GVL.
* ext/zlib/extconf.rb:  ditto
* NEWS:  ditto
* test/zlib/test_zlib.rb:  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-10 03:51:25 +00:00
drbrain 3e419e6c4a * ext/zlib/zlib.c: Added streaming support to inflate processing.
This allows zlib streams to be processed without huge memory growth.
  [Feature #6612]
* NEWS:  ditto
* ext/zlib/zlib.c (zstream_expand_buffer):  Uses rb_yield when a block
  is given for streaming support.  Refactored to use
  zstream_expand_buffer_into to remove duplicate code.
* ext/zlib/zlib.c (zstream_expand_buffer_protect):  Added wrapper
  function to pass jump state back through GVL-free section to allow
  zstream clean-up before terminating the ruby call.
* ext/zlib/zlib.c (zstream_expand_buffer_without_gvl):  Acquire GVL to
  yield processed chunk of output stream.
* ext/zlib/zlib.c (zstream_detach_buffer):  When a block is given,
  returns Qnil mid-stream and yields the output buffer at the end of
  the stream.
* ext/zlib/extconf.rb:  Update INCFLAGS to find internal.h for
  rb_thread_call_with_gvl
* test/zlib/test_zlib.rb:  Updated tests


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-10 00:04:47 +00:00
drbrain 0e9b0c8c84 * test/zlib/test_zlib.rb (test_inflate_partial_input): Added test for
inflating incomplete zlib streams.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-03 22:08:04 +00:00
naruse 95d4b3ba49 * test/zlib/test_zlib.rb (test_inflate): add a test for Zlib.inflate.
patched by headius (Charles Nutter). [ruby-core:44859] [Bug #6398]

* test/zlib/test_zlib.rb (test_deflate): add a test for Zlib.deflate.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-04 17:07:18 +00:00
nahi d77f31b635 * test/zlib/test_zlib.rb (TestZlibGzipReader#test_encoding): Add
encoding testcases for GzipReader#read.  read() emits 
  Encoding.default_external in contrast to read(size) emits BINARY.
  See also: http://bugs.jruby.org/6208


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-24 09:25:14 +00:00
drbrain 1516f8eb9f * ext/zlib/zlib.c (rb_inflate_add_dictionary): Added
Zlib::Inflate#add_dictionary to allow users to pre-specify
  for using during #inflate.  [ruby-trunk - Feature #5937]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-11 00:37:44 +00:00
drbrain 403dc5357d * ext/zlib/zlib.c (do_inflate): Inflate more data if buffered data
exists.  Allows Zlib::Inflate#set_dictionary to work.
  [ruby-trunk - Bug #5929]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-11 00:29:52 +00:00
shirosaki 11de7c034b * test/zlib/test_zlib.rb (TestZlibGzipReader#test_reader_wrap): set
binmode explicitly for fixing test error on Windows. This is consistent
  with r34243.
  [ruby-dev:45149] [Bug #5812]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-28 00:51:33 +00:00
usa 98ddbafb26 * test/zlib/test_zlib.rb (TestZlibGzipWriter#test_writer_wrap): set
binmode explicitly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-09 10:42:18 +00:00
nahi e3e985064a * ext/zlib/zlib.c (gzfile_read_header): Ensure that each section of
gzip header is readable to avoid SEGV.

* test/zlib/test_zlib.rb (test_corrupted_header): Test it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-23 02:36:13 +00:00
nobu b6371b55de * ext/zlib/zlib.c (gzfile_reader_get_unused): no need to dup
before rb_str_resurrect.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-03 15:15:04 +00:00
naruse b4940b61e3 e ext/zlib/zlib.c (gzfile_reader_get_unused): use rb_str_resurrect
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-03 09:56:52 +00:00
nobu 91c6ba2333 * ext/zlib/zlib.c (gzreader_gets): support optional length
parameter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25 02:02:55 +00:00
nobu bd3c7a7e90 * test/zlib/test_zlib.rb (test_readline): renamed from test_gets.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25 01:54:28 +00:00
usa fc233f516c * test/zlib/test_zlib.rb (test_to_io): forgotten to fix with r30201.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-15 02:20:37 +00:00
usa b33cb3c017 * test/zlib/test_zlib.rb (*): should close files associated with zlib.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-14 03:57:26 +00:00
nobu 01e1a0ac78 * ext/zlib/zlib.c (gzfile_raise): add invalid header to
exceptions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-07 02:44:04 +00:00
usa fa1044927f * test/zlib/test_zlib.rb (test_adler32_combine, test_crc32_combine): skip if
they are not implemented.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-19 02:42:57 +00:00
akr 47b8a0e7e4 avoid method redefinition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-14 03:09:53 +00:00
tenderlove 4395758903 * ext/zlib/zlib.c: added Zlib.crc32_combine and Zlib.adler32_combine
* test/zlib/test_zlib.rb: corresponding tests [ruby-core:27551]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-19 00:06:04 +00:00