26534 Commits
Author SHA1 Message Date
usa bbda1a0274 merge revision(s) 62968:
webrick: prevent response splitting and header injection

	Original patch by tenderlove (with minor style adjustments).

	* lib/webrick/httpresponse.rb (send_header): call check_header
	  (check_header): raise on embedded CRLF in header value
	* test/webrick/test_httpresponse.rb
	  (test_prevent_response_splitting_headers): new test
	* (test_prevent_response_splitting_cookie_headers): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@63022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28 14:50:27 +00:00
usa a45622669b merge revision(s) 62960-62965:
webrick: use IO.copy_stream for multipart response

	Use the new Proc response body feature to generate a multipart
	range response dynamically.  We use a flat array to minimize
	object overhead as much as possible; as many ranges may fit
	into an HTTP request header.

	* lib/webrick/httpservlet/filehandler.rb (multipart_body): new method
	  (make_partial_content): use multipart_body
	------------------------------------------------------------------------
	r62960 | normal | 2018-03-28 17:06:23 +0900 (水, 28 3 2018) | 13 lines

	webrick/httprequest: limit request headers size

	We use the same 112 KB limit started (AFAIK) by Mongrel, Thin,
	and Puma to prevent malicious users from using up all the memory
	with a single request.  This also limits the damage done by
	excessive ranges in multipart Range: requests.

	Due to the way we rely on IO#gets and the desire to keep
	the code simple, the actual maximum header may be 4093 bytes
	larger than 112 KB, but we're splitting hairs at that point.

	* lib/webrick/httprequest.rb: define MAX_HEADER_LENGTH
	  (read_header): raise when headers exceed max length
	------------------------------------------------------------------------
	r62961 | normal | 2018-03-28 17:06:28 +0900 (水, 28 3 2018) | 9 lines

	webrick/httpservlet/cgihandler: reduce memory use

	WEBrick::HTTPRequest#body can be passed a block to process the
	body in chunks.  Use this feature to avoid building a giant
	string in memory.

	* lib/webrick/httpservlet/cgihandler.rb (do_GET):
	  avoid reading entire request body into memory
	  (do_POST is aliased to do_GET, so it handles bodies)
	------------------------------------------------------------------------
	r62962 | normal | 2018-03-28 17:06:34 +0900 (水, 28 3 2018) | 7 lines

	webrick/httprequest: raise correct exception

	"BadRequest" alone does not resolve correctly, it is in the
	HTTPStatus namespace.

	* lib/webrick/httprequest.rb (read_chunked): use correct exception
	* test/webrick/test_httpserver.rb (test_eof_in_chunk): new test
	------------------------------------------------------------------------
	r62963 | normal | 2018-03-28 17:06:39 +0900 (水, 28 3 2018) | 9 lines

	webrick/httprequest: use InputBufferSize for chunked requests

	While WEBrick::HTTPRequest#body provides a Proc interface
	for streaming large request bodies, clients must not force
	the server to use an excessively large chunk size.

	* lib/webrick/httprequest.rb (read_chunk_size): limit each
	  read and block.call to :InputBufferSize in config.
	* test/webrick/test_httpserver.rb (test_big_chunks): new test
	------------------------------------------------------------------------
	r62964 | normal | 2018-03-28 17:06:44 +0900 (水, 28 3 2018) | 9 lines

	webrick: add test for Digest auth-int

	No changes to the actual code, this is a new test for
	a feature for which no tests existed.  I don't understand
	the Digest authentication code well at all, but this is
	necessary for the subsequent change.

	* test/webrick/test_httpauth.rb (test_digest_auth_int): new test
	  (credentials_for_request): support bodies with POST
	------------------------------------------------------------------------
	r62965 | normal | 2018-03-28 17:06:49 +0900 (水, 28 3 2018) | 18 lines

	webrick/httpauth/digestauth: stream req.body

	WARNING! WARNING! WARNING!  LIKELY BROKEN CHANGE

	Pass a proc to WEBrick::HTTPRequest#body to avoid reading a
	potentially large request body into memory during
	authentication.

	WARNING! this will break apps completely which want to do
	something with the body besides calculating the MD5 digest
	of it.

	Also, keep in mind that probably nobody uses "auth-int".
	Servers such as Apache, lighttpd, nginx don't seem to
	support it; nor does curl when using POST/PUT bodies;
	and we didn't have tests for it until now...

	* lib/webrick/httpauth/digestauth.rb (_authenticate): stream req.body

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@63021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28 14:47:30 +00:00
usa 19cb3fa9e0 merge revision(s) 60584,62954-62959,63008:
webrick: support Proc objects as body responses

	* lib/webrick/httpresponse.rb (send_body): call send_body_proc
	  (send_body_proc): new method
	  (class ChunkedWrapper): new class

	* test/webrick/test_httpresponse.rb (test_send_body_proc): new test
	  (test_send_body_proc_chunked): ditto
	  [Feature #855]

	webrick: favor .write over << method

	This will make the next change to use IO.copy_stream
	easier-to-read.  When we can drop Ruby 2.4 support in a few
	years, this will allow us to use writev(2) with multiple
	arguments for headers and chunked responses.

	* lib/webrick/cgi.rb (write): new wrapper method
	  lib/webrick/httpresponse.rb: (send_header): use socket.write
	  (send_body_io): ditto
	  (send_body_string): ditto
	  (send_body_proc): ditto
	  (_write_data): ditto
	  (ChunkedWrapper#write): ditto
	  (_send_file): ditto
	------------------------------------------------------------------------
	r62954 | normal | 2018-03-28 17:05:52 +0900 (水, 28 3 2018) | 14 lines

	webrick/httpresponse: IO.copy_stream for regular files

	Remove the redundant _send_file method since its functionality
	is unnecessary with IO.copy_stream.  IO.copy_stream also allows
	the use of sendfile under some OSes to speed up copies to
	non-TLS sockets.

	Testing with "curl >/dev/null" and "ruby -run -e httpd" to
	read a 1G file over Linux loopback reveals a reduction from
	around ~0.770 to ~0.490 seconds on the client side.

	* lib/webrick/httpresponse.rb (send_body_io): use IO.copy_stream
	  (_send_file): remove
	  [Feature #14237]
	------------------------------------------------------------------------
	r62955 | normal | 2018-03-28 17:05:57 +0900 (水, 28 3 2018) | 10 lines

	webrick: use IO.copy_stream for single range response

	This is also compatible with range responses generated
	by Rack::File (tested with rack 2.0.3).

	* lib/webrick/httpresponse.rb (send_body_io): use Content-Range
	* lib/webrick/httpservlet/filehandler.rb (make_partial_content):
	  use File object for the single range case
	* test/webrick/test_filehandler.rb (get_res_body): use send_body
	  to test result
	------------------------------------------------------------------------
	r62956 | normal | 2018-03-28 17:06:02 +0900 (水, 28 3 2018) | 7 lines

	test/webrick/test_filehandler.rb: stricter multipart range test

	We need to ensure we generate compatibile output in
	the face of future changes

	* test/webrick/test_filehandler.rb (test_make_partial_content):
	  check response body
	------------------------------------------------------------------------
	r62957 | normal | 2018-03-28 17:06:08 +0900 (水, 28 3 2018) | 8 lines

	webrick: quiet warning for multi-part ranges

	Content-Length is ignored by WEBrick::HTTPResponse even if we
	calculate it, so instead we chunk responses to HTTP/1.1 clients
	and terminate HTTP/1.0 connections.

	* lib/webrick/httpservlet/filehandler.rb (make_partial_content):
	  quiet warning
	------------------------------------------------------------------------
	r62958 | normal | 2018-03-28 17:06:13 +0900 (水, 28 3 2018) | 7 lines

	webrick/httpresponse: make ChunkedWrapper copy_stream-compatible

	The .write method needs to return the number of bytes written
	to avoid confusing IO.copy_stream.

	* lib/webrick/httpresponse.rb (ChunkedWrapper#write): return bytes written
	  (ChunkedWrapper#<<): return self
	------------------------------------------------------------------------
	r62959 | normal | 2018-03-28 17:06:18 +0900 (水, 28 3 2018) | 9 lines

	webrick: use IO.copy_stream for multipart response

	Use the new Proc response body feature to generate a multipart
	range response dynamically.  We use a flat array to minimize
	object overhead as much as possible; as many ranges may fit
	into an HTTP request header.

	* lib/webrick/httpservlet/filehandler.rb (multipart_body): new method
	  (make_partial_content): use multipart_body

	get rid of test error/failure on Windows introduced at r62955

	* lib/webrick/httpresponse.rb (send_body_io): use seek if NotImplementedError
	  is raised in IO.copy_stream with offset.

	* lib/webrick/httpservlet/filehandler.rb (multipart_body): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@63020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28 14:44:20 +00:00
usa 4cd92d7b13 merge revision(s) 62992:
pack.c: fix underflow

	* pack.c (pack_unpack_internal): get rid of underflow.
	  https://hackerone.com/reports/298246

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@63019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28 14:38:39 +00:00
usa 47165eed26 merge revision(s) 62991,63000:
unixsocket.c: check NUL bytes

	* ext/socket/unixsocket.c (rsock_init_unixsock): check NUL bytes.
	  https://hackerone.com/reports/302997

	unixsocket.c: abstract namespace

	* ext/socket/unixsocket.c (unixsock_path_value): fix r62991 for
	  Linux abstract namespace.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@63018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28 14:36:23 +00:00
usa e9ddf2ba41 merge revision(s) 62990:
Ignore file separator from tmpfile/tmpdir name.

	From: SHIBATA Hiroshi <hsbt@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@63017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28 14:34:14 +00:00
usa 143eb22f18 merge revision(s) 62989:
dir.c: check NUL bytes

	* dir.c (GlobPathValue): should be used in rb_push_glob only.
	  other methods should use FilePathValue.
	  https://hackerone.com/reports/302338

	* dir.c (rb_push_glob): expand GlobPathValue

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@63015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28 14:27:51 +00:00
usa 20ad678dfd merge revision(s) 62422,62436: [Backport #14481]
Merge RubyGems 2.7.6 from upstream.

	It fixed some security vulnerabilities.

	http://blog.rubygems.org/2018/02/15/2.7.6-released.html

	fix regexp literal warning.

	* test/rubygems/test_gem_server.rb: eliminate duplicated character class warning.
	  [Bug #14481]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@62443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16 16:35:55 +00:00
usa 664b94fd2b merge revision(s) 58471,58493,62436: [Backport #13505]
load.c: backtrace of circular require

	* load.c (load_lock): print backtrace of circular require via
	  `Warning.warn` [ruby-core:80850] [Bug #13505]

	  Send the backtrace of the circular require warning as a single String to Warning.warn

	* load.c: send as a single string.
	* error.c: expose the string formatted by rb_warning as rb_warning_string().
	* test/ruby/test_exception.rb: update tests.
	  [ruby-core:80850] [Bug #13505]

	fix regexp literal warning.

	* test/rubygems/test_gem_server.rb: eliminate duplicated character class warning.
	  [Bug #14481]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@62441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16 16:27:56 +00:00
usa 02b8978ff1 * test/net/ftp/test_ftp.rb (process_port_or_eprt): merge a part of
r56973 to pass the test introduced at previous commit.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@61255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 15:08:49 +00:00
usa 0207c68ea3 merge revision(s) 61242: [Backport #14185]
Fix a command injection vulnerability in Net::FTP.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@61246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 13:53:48 +00:00
usa fc824f2a81 merge revision(s) 60149: [Backport #14003]
Merge rubygems-2.6.14 changes.

	  It fixed http://blog.rubygems.org/2017/10/09/unsafe-object-deserialization-vulnerability.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@61244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 13:50:12 +00:00
usa d629ce0baa * ext/json: bump to version 1.8.1.1. [Backport #13853]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@59904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 11:44:37 +00:00
usa 5450329ad1 asn1: fix out-of-bounds read in decoding constructed objects
* OpenSSL::ASN1.{decode,decode_all,traverse}: have a bug of
  out-of-bounds read. int_ossl_asn1_decode0_cons() does not give the
  correct available length to ossl_asn1_decode() when decoding the
  inner components of a constructed object. This can cause
  out-of-bounds read if a crafted input given.

Reference: https://hackerone.com/reports/170316
https://github.com/ruby/openssl/commit/1648afef33c1d97fb203c82291b8a61269e85d3b


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@59903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 11:41:59 +00:00
usa 8a81d04d25 merge revision(s) 59897:
lib/webrick/log.rb: sanitize any type of logs

	It had failed to sanitize some type of exception messages.  Reported and
	patched by Yusuke Endoh (mame) at https://hackerone.com/reports/223363

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@59902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 11:37:47 +00:00
usa 4fdfb28e7d merge revision(s) 58453,58454: [Backport #13499]
Fix space flag when Inf/NaN and width==3

	* sprintf.c (rb_str_format): while `"% 2f"` and `"% 4f"` result in
	  `" Inf"` and `" Inf"` respectively, `"% 3f"` results in
	  `"Inf"` (no space).
	Refactor "%f" % Inf/NaN

	* sprintf.c (rb_str_format): as for non-finite float, calculate
	  the exact needed size with the space flag.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@59901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 11:35:52 +00:00
usa 97c6e3934c * lib/rubygems: fix several vulnerabilities in RubyGems; bump to version
2.4.5.3. [Backport #13842]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@59805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-10 01:10:24 +00:00
usa 366c5481e6 * ext/psych/yaml: update libyaml to 0.1.7.
* ext/psych/psych.gemspec: bump version to 2.0.8.1.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@59793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-09 12:24:22 +00:00
usa b2638c9f19 merge revision(s) 58084: [Backport #13361]
configure.in: syscall is deprecated on macOS

	* configure.in: syscall is no longer supported on macOS since
	  10.12.  [ruby-core:80300] [Bug #13361]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-28 06:40:22 +00:00
usa b411090c86 merge revision(s) 53566:
* configure.in: improve ICC (Intel C Compiler) support.

	* configure.in (CXX): The name of icc's c++ compiler is `icpc`.

	* configure.in (warnings): Add `-diag-disable=2259` to suppress
	  noisy warnings: "non-pointer conversion from "..." to "..." may
	  lose significant bits".

	* configure.in (optflags): Add `-fp-model precise` like -fno-fast-math.

	* lib/mkmf.rb: icc supports -Werror=division-by-zero
	  and -Werror=deprecated-declarations, but doesn't support
	  -Wdivision-by-zero and -Wdeprecated-declarations.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-26 16:42:03 +00:00
usa ce3ea463ba * thread.c (rb_thread_fd_close): unintentionally removed at r58094.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-26 08:25:14 +00:00
usa 1fb37c4c1a * test/ruby/test_thread.rb (test_thread_interrupt_for_killed_thread):
may fix the test failure on some platforms introduced at r58108.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-26 07:25:05 +00:00
usa b2cdb79c7a merge revision(s) 49806:
envutil.rb: timeout_error argument to invoke_ruby

	* test/lib/envutil.rb (invoke_ruby): add `timeout_error` optional
	  keyword argument, the exception class to be raised if the target
	  process timed out.  if it is nil, no exception will be raised at
	  timeout but the terminated output, error, and status will be
	  returned.  defaulted to Timeout::Error.

	* test/lib/envutil.rb (assert_separately): check outputs and
	  status (including diagnostic reports) of timed-out process.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-26 07:22:44 +00:00
usa 7b9fffe6a4 * thread.c (rb_thread_sleep_deadly_allow_spurious_wakeup): need to
mark as exported.  this may fix the load error introduced at r58115.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-26 04:11:55 +00:00
usa 9c3d2ca6ae * ChangeLog: log for r58102.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 20:31:44 +00:00
usa 544c352ec6 * ChangeLog: logs for r58085 - r58129.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 20:30:29 +00:00
usa ed20b2561c merge revision(s) 51871,51872,51874,51875,51876,51877,51878,57517: [Backport #13190]
* doc/syntax/literals.rdoc (Strings): mention about ?a literal.

	literals.rdoc: fix typos

	* doc/syntax/literals.rdoc (Strings): fix typos.
	* doc/syntax/literals.rdoc (Strings): [DOC] Document the full list
	  of supported escape sequences in string literals.

	* doc/syntax/literals.rdoc (Strings): [DOC] Revise the character
	  literal part.

	literals.rdoc: add DEL [ci skip]

	* doc/syntax/literals.rdoc (Strings): [DOC] add DEL.
	[DOC] `\0` is interpreted as NUL only if not followed by an octal digit.
	[DOC] Remove `\0` since it's aprt of octal notation

	A typo is fixed while at it.
	doc: Fix error for escape sequences in string literals

	Backslash goes first in escape sequences, so it must be
	"any other character following a backslash is interpreted as ...",
	while the doc says "...followed by...".

	Author: Marcus Stollsteimer <sto.mar@web.de>
	[ruby-core:79418] [Bug #13190]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 17:45:00 +00:00
usa bf2d4e93b1 merge revision(s) 54785: [Backport #11900]
* ruby.c (process_options): convert -e script to the encoding
	  given by a command line option on Windows.  assume it is the
	  expected encoding.  [ruby-dev:49461] [Bug #11900]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 17:35:52 +00:00
usa 8c34c05d24 merge revision(s) 56310: [Backport #13364]
* win32/win32.c (poll_child_status): rb_w32_wait_events_blocking() sets
	  errno internally, then should not set it here.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 17:32:17 +00:00
usa da0e21528b merge revision(s) 56125,56150: [Backport #12741]
* thread.c (rb_threadptr_raise): set cause from the called thread,
	  but not from the thread to be interrupted.
	  [ruby-core:77222] [Bug #12741]

	* test/ruby/test_exception.rb: fix thread issues.
	  * use Queue instead of a local variable for synchronization.
	  * join created thread to soleve leaking threads warning.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 17:13:49 +00:00
usa a14ba6e3d5 merge revision(s) 53383,55366: [Backport #12478]
* lib/forwardable.rb (def_instance_delegator): adjust backtrace of
	  method body by tail call optimization.  adjusting the delegated
	  target is still done by deleting backtrace.

	* lib/forwardable.rb (def_single_delegator): ditto.

	* lib/forwardable.rb (Forwardable._delegator_method): extract
	  method generator and deal with non-module objects.
	  [ruby-dev:49656] [Bug #12478]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 14:43:16 +00:00
usa ffb1a5d801 Revert r57229 and finally giving up backporting [Bug #13043]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-04 02:02:32 +00:00
usa d785c36b88 merge revision(s) 57137: [Backport #13043]
eval.c: fix circular cause

	* eval.c (exc_setup_cause): always set cause of cause to get rid
  of circular references.  [ruby-core:78688] [Bug #13043]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-28 21:00:45 +00:00
usa 543a8b5e3d revert r57222 because of SEGV
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 14:59:55 +00:00
usa 7015fcf9f8 merge revision(s) 57172: [Backport #13066]
time.c: fix type of usec2subsecx

	* time.c (usec2subsecx): fix return type, which is a numeric
  object but not a long int.  [ruby-dev:49912] [Bug #13066]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 11:44:17 +00:00
usa 9d693b181c merge revision(s) 57137: [Backport #13043]
eval.c: fix circular cause

	* eval.c (exc_setup_cause): always set cause of cause to get rid
  of circular references.  [ruby-core:78688] [Bug #13043]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 11:39:47 +00:00
usa f82b0a39ea merge revision(s) 57123: [Backport #13054]
re.c: consider the case of RMatch::regexp is nil

	Follow r49675, r57098 and r57110. Don't assume RMatch::regexp always
	contains a valid Regexp instance; it will be Qnil if the MatchData is
	created by rb_backref_set_string().  [ruby-core:78741] [Bug #13054]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 11:14:32 +00:00
usa 33b3645611 merge revision(s) 57119: [Backport #13052]
array.c: check array length every time after yielding

	Since the Array may be modified during rb_yield(), the length before
	invoking the block can't be trusted. Fix possible out-of-bounds read in
	Array#combination and Array#repeated_combination.

	It may better to make a defensive copy of the Array, but for now let's
	follow what Array#permutation does.  [ruby-core:78738] [Bug #13052]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 11:03:50 +00:00
usa 1bd82de997 merge revision(s) 57108: [Backport #13049]
sprintf.c: fix width underflow

	* sprintf.c (rb_str_format): fix memory corruption by width
  underflow.  https://github.com/mruby/mruby/issues/3347

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:58:14 +00:00
usa ea83d7fd06 merge revision(s) 57098: [Backport #13042]
re.c: non-regexp name reference

	* re.c (rb_reg_regsub): other than regexp has no name references.
  [ruby-core:78686] [Bug #13042]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:55:32 +00:00
usa 745565052a merge revision(s) 57078: [Backport #13034]
encoding.c: handle needmore error from rb_enc_precise_mbclen()

	rb_enc_ascget() erroneously reports success even if the given byte
	sequence is incomplete, for non-ASCII compatible encoding strings.

	rb_enc_precise_mbclen() may return a negative value on error, and thus
	rb_enc_ascget() must not store the return value in 'unsigned int';
	otherwise the subsequent MBCLEN_CHARFOUND_P() check won't catch the
	error.  [ruby-core:78646] [Bug #13034]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:52:35 +00:00
usa 04d79490da merge revision(s) 57020,57021: [Backport #13014]
Add clang volatile fixes from FreeBSD and NetBSD.

	Use volatile instead of optnone to avoid optimization which causes
	segmentation faults.
	Patch by Dimitry Andric.  [ruby-core:78531] [Bug #13014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:49:55 +00:00
usa ed8c211a64 merge revision(s) 56980,56981: [Backport #13004]
extension.rdoc: fix rb_get_kwargs [ci skip]

	* doc/extension.rdoc: [DOC] optional keyword arguments are
  defaulted to Qundef.  ignored keys are kept in the hash but a
  new Hash is not created.  [ruby-dev:49893] [Bug #13004]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:41:16 +00:00
usa 3aed194ac3 merge revision(s) 56938: [Backport #12988]
Stop reading past the end of `ivptr` array

	If you have code like this:

	```ruby
	class A
  def initialize
    @a = nil
    @b = nil
    @c = nil
    @d = nil
    @e = nil
  end
	end

	x = A.new
	y = x.clone
	100.times { |z| x.instance_variable_set(:"@foo#{z}", nil) }
	puts y.inspect
	```

	`x` and `y` will share `iv_index_tbl` hashes.  However, the size of the
	hash will grow larger than the number if entries in `ivptr` in `y`.
	Before this commit, `rb_ivar_count` would use the size of the hash to
	determine how far to read in to the array, but this means that it could
	read past the end of the array and cause the program to segv

	[ruby-core:78403]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:35:50 +00:00
usa 244885b637 merge revision(s) 56928: [Backport #12991]
thread.c: fix doc of abort_on_exception [ci skip]

	* thread.c (rb_thread_s_abort_exc, rb_thread_s_abort_exc_set):
  [DOC] the raised exception will be re-raised in the main thread,
  and then follows the ordinary exception sequence, exit status is
  not 0.  [ruby-core:78415] [Bug #12991]

	* thread.c (rb_thread_abort_exc_set): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:32:51 +00:00
usa e44b8733dd merge revision(s) 56905: [Backport #12983]
Reverse compatibility_version and current_version for Darwin

	The `compatibility_version` should have an API version and the
	`current_version` should have a program version of Ruby, but they have
	been reversed and the binary compatibility has never worked.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:30:35 +00:00
usa 88c68a89d3 merge revision(s) 56894: [Backport #12974]
marshal.c: fix infinite recursion

	* marshal.c (check_userdump_arg): marshal_dump should not return
  an instance of the same class, otherwise it causes infinite
  recursion.  [ruby-core:78289] [Bug #12974]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 10:11:49 +00:00
usa a078bbcc17 merge revision(s) 56469: [Backport #12860]
* compile.c (setup_args): duplicate splatting array if more
	  arguments present to obey left-to-right execution order.
	  [ruby-core:77701] [Bug# 12860]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 09:34:40 +00:00
usa 16d03ff2a4 * ChangeLog: for r57207 and r57208.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-27 09:32:48 +00:00
usa 30238f9608 merge revision(s) 53064: [Backport #11810]
* ext/openssl/ossl_ssl.c (ssl_npn_select_cb_common): fix parsing
	  protocol list.
	  The protocol list from OpenSSL is not null-terminated.
	  patched by Kazuki Yamaguchi [Bug #11810] [ruby-core:72082]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@56798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-15 06:33:36 +00:00