<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/ext/zlib/zlib.c, branch ruby_2_7</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) c51b92c18deb850d2cea3a7c9020db23b364ab72: [Backport #18358]</title>
<updated>2022-03-05T13:01:07+00:00</updated>
<author>
<name>NAKAMURA Usaku</name>
<email>usa@ruby-lang.org</email>
</author>
<published>2022-03-05T13:01:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=83de7133876ec392eb4b3b69c2220d7b49685444'/>
<id>83de7133876ec392eb4b3b69c2220d7b49685444</id>
<content type='text'>
    [ruby/zlib] [Bug #18358] Fix crash in zlib when in progress

    When Zlib::Inflate#inflate or Zlib::Deflate#deflate is called
    recursively inside the block, a crash can occur because of an
    use-after-free bug.

    https://github.com/ruby/zlib/commit/50fb8a0338
    ---
     ext/zlib/zlib.c        | 117 ++++++++++++++++++++++++++++++++-----------------
     test/zlib/test_zlib.rb |  10 ++++-
     2 files changed, 85 insertions(+), 42 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
    [ruby/zlib] [Bug #18358] Fix crash in zlib when in progress

    When Zlib::Inflate#inflate or Zlib::Deflate#deflate is called
    recursively inside the block, a crash can occur because of an
    use-after-free bug.

    https://github.com/ruby/zlib/commit/50fb8a0338
    ---
     ext/zlib/zlib.c        | 117 ++++++++++++++++++++++++++++++++-----------------
     test/zlib/test_zlib.rb |  10 ++++-
     2 files changed, 85 insertions(+), 42 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) b3d62a77d928eff01268ca7fa1c1c0966702926d [Backport #17803]</title>
<updated>2022-03-05T12:38:48+00:00</updated>
<author>
<name>NAKAMURA Usaku</name>
<email>usa@ruby-lang.org</email>
</author>
<published>2022-03-05T12:38:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f740ffb81f3ef11526add528583b0cbfce28af67'/>
<id>f740ffb81f3ef11526add528583b0cbfce28af67</id>
<content type='text'>
    [ruby/zlib] Synchronize access to zstream to prevent segfault in
     multithreaded use

    I'm not sure whether this handles all multithreaded use cases,
    but this handles the example that crashes almost immediately
    and does 10,000,000 total deflates using 100 separate threads.

    To prevent the tests from taking forever, the committed test
    for this uses only 10,000 deflates across 10 separate threads,
    which still causes a segfault in the previous implementation
    almost immediately.

    Fixes [Bug #17803]

    https://github.com/ruby/zlib/commit/4b1023b3f2
    ---
     ext/zlib/zlib.c        | 33 ++++++++++++++++++++++++++-
     test/zlib/test_zlib.rb | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
     2 files changed, 93 insertions(+), 1 deletion(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
    [ruby/zlib] Synchronize access to zstream to prevent segfault in
     multithreaded use

    I'm not sure whether this handles all multithreaded use cases,
    but this handles the example that crashes almost immediately
    and does 10,000,000 total deflates using 100 separate threads.

    To prevent the tests from taking forever, the committed test
    for this uses only 10,000 deflates across 10 separate threads,
    which still causes a segfault in the previous implementation
    almost immediately.

    Fixes [Bug #17803]

    https://github.com/ruby/zlib/commit/4b1023b3f2
    ---
     ext/zlib/zlib.c        | 33 ++++++++++++++++++++++++++-
     test/zlib/test_zlib.rb | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
     2 files changed, 93 insertions(+), 1 deletion(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 0c5f8c62766afe4605172800063e63fe36996658: [Backport #10961]</title>
<updated>2021-12-31T10:48:36+00:00</updated>
<author>
<name>NAKAMURA Usaku</name>
<email>usa@ruby-lang.org</email>
</author>
<published>2021-12-31T10:48:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1034b6e7ba9442320e16c260d634d4c64d5e62bf'/>
<id>1034b6e7ba9442320e16c260d634d4c64d5e62bf</id>
<content type='text'>
	[ruby/zlib] Resume zstream if available [Bug #10961]

	---
	 ext/zlib/zlib.c | 6 ++++++
	 1 file changed, 6 insertions(+)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[ruby/zlib] Resume zstream if available [Bug #10961]

	---
	 ext/zlib/zlib.c | 6 ++++++
	 1 file changed, 6 insertions(+)
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/zlib] Bump version to 1.1.0</title>
<updated>2019-11-30T09:21:52+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2019-11-30T09:20:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b94d06096b8f2a375719ce09370e004fcb277b25'/>
<id>b94d06096b8f2a375719ce09370e004fcb277b25</id>
<content type='text'>
https://github.com/ruby/zlib/commit/5af77c1ee8
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/zlib/commit/5af77c1ee8
</pre>
</div>
</content>
</entry>
<entry>
<title>Adjust a fucntion signature</title>
<updated>2019-11-04T17:05:46+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2019-11-04T17:02:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=929a4aa722524f4567eed0d8b27d644f912c22f7'/>
<id>929a4aa722524f4567eed0d8b27d644f912c22f7</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/zlib] Removed no longer used variables</title>
<updated>2019-10-31T13:24:00+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2019-10-31T13:21:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=63f70eb65160a53443ec76365e78a80948b54824'/>
<id>63f70eb65160a53443ec76365e78a80948b54824</id>
<content type='text'>
https://github.com/ruby/zlib/commit/3e98e4cac3
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/zlib/commit/3e98e4cac3
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/zlib] Fix setting mtime to zero in GzipWriter</title>
<updated>2019-10-31T13:23:58+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2019-10-25T23:15:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0aaa15f6362e307c9ef636e9625027b96e577dfb'/>
<id>0aaa15f6362e307c9ef636e9625027b96e577dfb</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/zlib] Remove taint support</title>
<updated>2019-10-31T06:34:01+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2019-10-18T19:45:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=290903dba01d97bc6869886eccef0378dcdd5e0c'/>
<id>290903dba01d97bc6869886eccef0378dcdd5e0c</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/zlib] Fix for older ruby 2.6 or earlier</title>
<updated>2019-09-29T09:53:11+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2019-09-29T09:52:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=94db8cda9b4eeee4736d089570a343fdf5ef86c0'/>
<id>94db8cda9b4eeee4736d089570a343fdf5ef86c0</id>
<content type='text'>
https://github.com/ruby/zlib/commit/00ead8cb2c
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/zlib/commit/00ead8cb2c
</pre>
</div>
</content>
</entry>
<entry>
<title>Make rb_scan_args handle keywords more similar to Ruby methods (#2460)</title>
<updated>2019-09-25T18:18:49+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2019-09-25T18:18:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=80b5a0ff2a7709367178f29d4ebe1c54122b1c27'/>
<id>80b5a0ff2a7709367178f29d4ebe1c54122b1c27</id>
<content type='text'>
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.

This makes the following changes to : handling.

* Treats as **kw, prompting keyword argument separation warnings
  if called with a positional hash.

* Do not look for an option hash if empty keywords are provided.
  For backwards compatibility, treat an empty keyword splat as a empty
  mandatory positional hash argument, but emit a a warning, as this
  behavior will be removed in Ruby 3.  The argument number check
  needs to be moved lower so it can correctly handle an empty
  positional argument being added.

* If the last argument is nil and it is necessary to treat it as an option
  hash in order to make sure all arguments are processed, continue to
  treat the last argument as the option hash. Emit a warning in this case,
  as this behavior will be removed in Ruby 3.

* If splitting the keyword hash into two hashes, issue a warning, as we
  will not be splitting hashes in Ruby 3.

* If the keyword argument is required to fill a mandatory positional
  argument, continue to do so, but emit a warning as this behavior will
  be going away in Ruby 3.

* If keyword arguments are provided and the last argument is not a hash,
  that indicates something wrong. This can happen if a cfunc is calling
  rb_scan_args multiple times, and providing arguments that were not
  passed to it from Ruby.  Callers need to switch to the new
  rb_scan_args_kw function, which allows passing of whether keywords
  were provided.

This commit fixes all warnings caused by the changes above.

It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used.  If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.

In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby.  The last argument may or may not be a hash,
so we can't set keyword argument mode.  However, if it is a
hash, we don't want to warn when treating it as keywords.

In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args.  Also, make
sure not to pass nil in place of an option hash.

Work around Kernel#warn warnings due to problems in the Rubygems
override of the method.  There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.

Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.

This makes the following changes to : handling.

* Treats as **kw, prompting keyword argument separation warnings
  if called with a positional hash.

* Do not look for an option hash if empty keywords are provided.
  For backwards compatibility, treat an empty keyword splat as a empty
  mandatory positional hash argument, but emit a a warning, as this
  behavior will be removed in Ruby 3.  The argument number check
  needs to be moved lower so it can correctly handle an empty
  positional argument being added.

* If the last argument is nil and it is necessary to treat it as an option
  hash in order to make sure all arguments are processed, continue to
  treat the last argument as the option hash. Emit a warning in this case,
  as this behavior will be removed in Ruby 3.

* If splitting the keyword hash into two hashes, issue a warning, as we
  will not be splitting hashes in Ruby 3.

* If the keyword argument is required to fill a mandatory positional
  argument, continue to do so, but emit a warning as this behavior will
  be going away in Ruby 3.

* If keyword arguments are provided and the last argument is not a hash,
  that indicates something wrong. This can happen if a cfunc is calling
  rb_scan_args multiple times, and providing arguments that were not
  passed to it from Ruby.  Callers need to switch to the new
  rb_scan_args_kw function, which allows passing of whether keywords
  were provided.

This commit fixes all warnings caused by the changes above.

It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used.  If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.

In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby.  The last argument may or may not be a hash,
so we can't set keyword argument mode.  However, if it is a
hash, we don't want to warn when treating it as keywords.

In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args.  Also, make
sure not to pass nil in place of an option hash.

Work around Kernel#warn warnings due to problems in the Rubygems
override of the method.  There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.

Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.</pre>
</div>
</content>
</entry>
</feed>
