12961 Commits
Author SHA1 Message Date
Nobuyoshi Nakada be9026a7b4 Test for quadratic backtracking on invalid time
https://hackerone.com/reports/1485501
2023-03-30 19:48:27 +09:00
Nobuyoshi Nakada 33c0889ca3 Historical timezones of Lisbon in tzdata are unstable 2023-03-29 10:57:28 +09:00
Takashi Kokubun ab2fabf34d Skip test_europe_lisbon on macOS
until we figure out why it's failing.
2023-03-29 10:57:28 +09:00
Hiroshi SHIBATA 6855779d58 Merge URI-0.10.0.2 2023-03-29 10:17:23 +09:00
NAKAMURA Usaku 36cadad643 merge revision(s) 58cc3c9f: [Backport #19187]
[Bug #19187] Fix for tzdata-2022g

	---
	 test/ruby/test_time_tz.rb | 21 +++++++++++++++------
	 1 file changed, 15 insertions(+), 6 deletions(-)
2022-12-08 12:33:58 +09:00
Nobuyoshi Nakada fa7fab95b9 Removed unnecessary RLIMIT_AS
Even without this limit, these assertions almost certainly cause a
NoMemoryError by removing the fix in 72ad8595f2.
2022-11-24 11:20:51 +09:00
nagachika 25df68ae91 merge revision(s) dae843f6b7502f921a7e66f39e3714a39d860181,86096a91d55f72620e0f8ca8634da5fa342dc35b:
Bypass git submodule add/update with git config
	 protocol.file.allow=always option.

	Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
	---
	 test/rubygems/test_gem_source_git.rb | 5 +++++
	 1 file changed, 5 insertions(+)

	[rubygems/rubygems] Use [] instead of double-quotes

	---
	 test/rubygems/test_gem_source_git.rb | 2 +-
	 1 file changed, 1 insertion(+), 1 deletion(-)
2022-11-24 11:20:51 +09:00
Hiroshi SHIBATA 7cf697179d Merge CGI-0.1.0.2 2022-11-24 11:20:51 +09:00
NAKAMURA Usaku c9c2245c0a Fix dtoa buffer overrun 2022-04-12 20:25:48 +09:00
NAKAMURA Usaku 334ca2dc06 merge revision(s) 496591de96: [Backport #18578]
st.c: Do not clear entries_bound when calling Hash#shift for empty
     hash

    tab->entries_bound is used to check if the bins are full in
    rebuild_table_if_necessary.

    Hash#shift against an empty hash assigned 0 to tab->entries_bound, but
    didn't clear the bins. Thus, the table is not rebuilt even when the bins
    are full. Attempting to add a new element into full-bin hash gets stuck.

    This change stops clearing tab->entries_bound in Hash#shift.
    [Bug #18578]
    ---
     st.c                   |  1 -
     test/ruby/test_hash.rb | 13 +++++++++++++
     2 files changed, 13 insertions(+), 1 deletion(-)
2022-03-19 22:50:51 +09:00
NAKAMURA Usaku 19fec939a6 merge revision(s) c79d2e5474: [Backport #18562]
Fix TAG_THROW through require [Bug #18562]

    Previously this was being incorrectly swapped with TAG_RAISE in the next
    line. This would end up checking the T_IMEMO throw_data to the exception
    handling (which calls Module#===). This happened to not break existing
    tests because Module#=== returned false when klass is NULL.

    This commit handles throw from require correctly by jumping to the tag
    retaining the TAG_THROW state.
    ---
     load.c                      |  2 +-
     test/ruby/test_exception.rb | 21 +++++++++++++++++++++
     2 files changed, 22 insertions(+), 1 deletion(-)
2022-03-19 22:45:51 +09:00
NAKAMURA Usaku 7eaec9a6b3 merge revision(s) b555e659c4: [Backport #18388]
Do not use `fcopyfile` if appending to non-empty file [Bug #18388]

    `fcopyfile` appends `src` to `to` and then truncates `to` to it's
    original size.
    ---
     io.c                 |  7 +++++++
     test/ruby/test_io.rb | 12 ++++++++++++
     2 files changed, 19 insertions(+)
2022-03-19 22:41:16 +09:00
NAKAMURA Usaku 5da2a3e316 merge revision(s) 7ff1bf317887c0d7b21e91ad548d07b9f05c540c,e89d80702bd98a8276243a7fcaa2a158b3bfb659: [Backport #18516]
An alias can suppress method redefinition warning

    ---
     test/ruby/test_alias.rb | 11 +++++++++++
     1 file changed, 11 insertions(+)

    Fix memory leak at the same named alias [Bug #18516]

    When aliasing a method to the same name method, set a separate bit
    flag on that method definition, instead of the reference count
    increment.  Although this kind of alias has no actual effect at
    runtime, is used as the hack to suppress the method re-definition
    warning.
    ---
     method.h                |  1 +
     test/ruby/test_alias.rb | 18 ++++++++++++++++++
     vm_method.c             |  9 ++++++++-
     3 files changed, 27 insertions(+), 1 deletion(-)
2022-03-19 22:34:37 +09:00
NAKAMURA Usaku 81f5453bd8 merge revision(s) 5c7af72304d0ad33cd3f21b24a4bc44e8acd5b2c,d650b17686d49c2ce8e6a87039861154e93d4621: [Backport #18497]
Assuming EXIT_SUCCESS equals 0 is not portable

    ---
     test/ruby/test_fiber.rb | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)

    `rb_fiber_terminate` must not return [Bug #18497]

    In a forked process from a fiber, the fiber becomes the only
    fiber, `fiber_switch` does nothing as there is no other fibers,
    `rb_fiber_terminate` does not terminate the fiber.  In that case,
    reaches the end of `fiber_entry` finaly, which is declared as
    "COROUTINE" and should never return.
    ---
     cont.c                     |  3 ++-
     eval_intern.h              |  2 +-
     test/fiber/test_process.rb | 15 +++++++++++++++
     test/ruby/test_fiber.rb    |  5 +++++
     4 files changed, 23 insertions(+), 2 deletions(-)

    note that only backported a part of above patch because of incompatibility
    of ruby_2_7.
2022-03-19 22:23:08 +09:00
NAKAMURA Usaku ea9b0fe5d3 merge revision(s) ae5458f228: [Backport #18475]
thread.c: Convert TAG_BREAK to a normal exception at thread top-level

    [Bug #18475]
    ---
     test/ruby/test_enum.rb | 11 +++++++++++
     thread.c               |  3 +++
     2 files changed, 14 insertions(+)
2022-03-19 22:15:40 +09:00
NAKAMURA Usaku 83de713387 merge revision(s) c51b92c18d: [Backport #18358]
[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(-)
2022-03-05 22:01:07 +09:00
NAKAMURA Usaku f740ffb81f merge revision(s) b3d62a77d9 [Backport #17803]
[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(-)
2022-03-05 21:38:48 +09:00
NAKAMURA Usaku 1cc5567b46 merge revision(s) 0846c2da457e7523819236ac7da492029b3ef73d,6c7cb00c094332a208cf36e5cd723a9ba60c41b8: [Backport #16376]
Check backref number buffer overrun [Bug #16376]

	---
	 regcomp.c                | 21 ++++++++++++---------
	 test/ruby/test_regexp.rb |  6 ++++++
	 2 files changed, 18 insertions(+), 9 deletions(-)

	test/ruby/test_regexp.rb: Avoid "ambiguity between regexp and two
	 divisions"

	---
	 test/ruby/test_regexp.rb | 2 +-
	 1 file changed, 1 insertion(+), 1 deletion(-)
2021-12-31 19:48:29 +09:00
NAKAMURA Usaku 426266af2c merge revision(s) fdf3996349: [Backport #18421]
Empty and return the buffer if zero size is given [Bug #18421]

	In `IO#readpartial` and `IO#read_nonblock`, as well as `IO#read`.
	---
	 io.c                 |  8 ++++++--
	 test/ruby/test_io.rb | 21 +++++++++++++++++++++
	 2 files changed, 27 insertions(+), 2 deletions(-)
2021-12-31 19:48:24 +09:00
NAKAMURA Usaku 7d3cff6e41 merge revision(s) a2d4e1cda68a49980a4f9f353f400efbde7e7884,d6c5a30cfdf658280338dbb8c8b17fab3190b928: [Backport #18392]
Fixed the check order in wmap_live_p [Bug #18392]

	Check if the object is a pointer to heap before check the flag in
	that object.
	---
	 gc.c | 35 ++++++++++++++++++++++-------------
	 1 file changed, 22 insertions(+), 13 deletions(-)

	ObjectSpace::WeakMap#inspect: check if living object [Bug #18392]

	---
	 gc.c                      | 29 +++++++++++++++++++++++------
	 test/ruby/test_weakmap.rb |  9 +++++++++
	 2 files changed, 32 insertions(+), 6 deletions(-)
2021-12-31 19:48:17 +09:00
NAKAMURA Usaku f69aeb8314 merge some parts of CGI 0.1.1
Fix integer overflow

	Make use of the check in rb_alloc_tmp_buffer2.

	When parsing cookies, only decode the values

	Bump version
2021-11-24 20:21:17 +09:00
NAKAMURA Usaku b198562956 merge revision(s) e83c02a768: [Backport #18289]
Delegate keywords from Enumerable#to_a to #each

	Fixes [Bug #18289]
	---
	 enum.c                 | 2 +-
	 test/ruby/test_enum.rb | 5 +++++
	 2 files changed, 6 insertions(+), 1 deletion(-)
2021-11-24 19:38:18 +09:00
NAKAMURA Usaku 1d4e037a80 merge revision(s) a4d5ee4f31: [Backport #18264]
[Bug #18264] Fix memory leak in TracePoint

	TracePoint leaks memory because it allocates a `rb_tp_t` struct
	without ever freeing it (it is created with `RUBY_TYPED_NEVER_FREE`).
	---
	 test/ruby/test_settracefunc.rb | 10 ++++++++++
	 vm_trace.c                     |  2 +-
	 2 files changed, 11 insertions(+), 1 deletion(-)
2021-11-24 19:37:50 +09:00
NAKAMURA Usaku 419266d44c merge revision(s) 89242279e61b023a81c58065c62a82de8829d0b3,529fc204af84f825f98f83c34b004acbaa802615: [Backport #18141]
Marshal.load: do not call the proc until strings have their encoding

	Ref: https://bugs.ruby-lang.org/issues/18141
	---
	 marshal.c                             |  7 +++-
	 spec/ruby/core/marshal/shared/load.rb | 62 +++++++++++++++++++++++------------
	 test/ruby/test_marshal.rb             | 17 ++++++++++
	 3 files changed, 64 insertions(+), 22 deletions(-)

	marshal.c: don't call the proc with partially initialized objects.
	 (#4866)

	For cyclic objects, it requires to keep a st_table of the partially
	initialized objects.
	---
	 marshal.c                             | 75 ++++++++++++++++++++---------------
	 spec/ruby/core/marshal/shared/load.rb | 75 ++++++++++++++++++++---------------
	 test/ruby/test_marshal.rb             | 12 ++++++
	 3 files changed, 97 insertions(+), 65 deletions(-)
2021-11-24 19:36:07 +09:00
NAKAMURA Usaku 61a02168f7 merge revision(s) ddb32e6616: [Backport #18173]
[Bug #18173] Update loaded_features_index

	If $LOADED_FEATURES is changed in the just required file, also the
	index table needs to be updated before loaded_features_snapshot is
	reset.  If the snapshot is reset without updating the table, the
	name of the added feature will not be found.
	---
	 load.c                    |  1 +
	 test/ruby/test_require.rb | 17 +++++++++++++++++
	 2 files changed, 18 insertions(+)
2021-11-24 19:34:59 +09:00
NAKAMURA Usaku cd10572b05 merge revision(s) 99d8c4832a: [Backport #18160]
Preserve the encoding of the argument in IndexError [Bug #18160]

	---
	 re.c                     | 20 ++++++++++----------
	 test/ruby/test_regexp.rb |  7 ++++++-
	 2 files changed, 16 insertions(+), 11 deletions(-)
2021-11-24 19:34:03 +09:00
NAKAMURA Usaku d55426f800 merge revision(s) 5d81554281: [Backport #18154]
[Bug #18154] Fix memory leak in String#initialize

	String#initialize can leak memory when called on a string that is marked
	with STR_NOFREE because it does not unset the STR_NOFREE flag.
	---
	 string.c                 |  2 +-
	 test/ruby/test_string.rb | 10 ++++++++++
	 2 files changed, 11 insertions(+), 1 deletion(-)
2021-11-24 19:31:43 +09:00
Hiroshi SHIBATA ade896702e Merge date-3.0.3 2021-11-24 17:55:25 +09:00
Andrew Aladjev f180f4607c Backport mutexes for socket and connection lists on win32 #4212 2021-11-24 17:42:52 +09:00
PikachuEXE eeabac4c55 Do not allow Module#include to insert modules before the origin in the lookup chain
Module#include should only be able to insert modules after the origin,
otherwise it ends up working like Module#prepend.

This fixes the case where one of the modules in the included module
chain is included in a module that is already prepended to the receiver.

Fixes [Bug #7844]

Backport of https://github.com/ruby/ruby/pull/3796 to 2.7
2021-11-24 16:47:15 +09:00
Kazuki Yamaguchi e0b323632f openssl: import v2.1.3
Bring the local copy of ruby/openssl in sync with the upstream gem
release v2.1.3. The commits happened in the upstream repository can be
found at:

	https://github.com/ruby/openssl/compare/v2.1.2...v2.1.3

Note that many of these have already been applied to ruby.git and don't
appear in the file changes of this commit.
2021-11-24 16:45:46 +09:00
Yusuke EndohandShugo Maeda a21a3b7d23 Fix StartTLS stripping vulnerability
Reported by Alexandr Savca in https://hackerone.com/reports/1178562

Co-authored-by: Shugo Maeda <shugo@ruby-lang.org>
2021-07-07 19:48:22 +09:00
Yusuke EndohandShugo Maeda 3ca1399150 Ignore IP addresses in PASV responses by default, and add new option use_pasv_ip
This fixes CVE-2021-81810.
Reported by Alexandr Savca.

Co-authored-by: Shugo Maeda <shugo@ruby-lang.org>
2021-07-07 19:47:46 +09:00
NAKAMURA Usaku 483f303d02 merge revision(s) a7f5d6ab88 c9ab8fe2 [Backport#17877]
a fix of RDoc for CVE-2021-31799
2021-05-31 23:44:23 +09:00
NAKAMURA Usaku fd95a18059 merge revision(s) d8a13e5049: [Backport #17780]
[Bug #17780] Fix Method#super_method for module alias

	Method#super_method crashes for aliased module methods because they are
	not defined on a class. This bug was introduced in
	c60aaed185 as part of bug #17130.
	---
	 proc.c                   |  2 +-
	 test/ruby/test_method.rb | 13 +++++++++++++
	 2 files changed, 14 insertions(+), 1 deletion(-)
2021-05-31 23:01:45 +09:00
NAKAMURA Usaku 67f1cd20bf merge revision(s) fbbc37dc1d: [Backport #17802]
test/drb/test_drb.rb: Specify the host of DRbServer

	to try fixing the following error.

	http://rubyci.s3.amazonaws.com/opensuseleap/ruby-master/log/20210407T063004Z.log.html.gz
	```
	[  605/21105] DRbTests::TestDRbSSLAry#test_06_next/home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/lib/drb/drb.rb:1138:in `method_missing': undefined method `regist' for [1, 2, "III", 4, "five", 6]:Array (NoMethodError)
		from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/lib/drb/extserv.rb:21:in `block in initialize'
		from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/.ext/common/monitor.rb:202:in `synchronize'
		from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/.ext/common/monitor.rb:202:in `mon_synchronize'
		from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/lib/drb/extserv.rb:20:in `initialize'
		from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/test/drb/ut_array_drbssl.rb:35:in `new'
		from /home/chkbuild/chkbuild/tmp/build/20210407T063004Z/ruby/test/drb/ut_array_drbssl.rb:35:in `<main>'
	 = 100.05 s
	```

	Here is my analysis:
	The test of drb used both `druby://:0` and `druby://localhost:0` for
	DRbServer. However, the former listens on IPv4, and the latter does on
	IPv6, depending on environments. The port 0 is automatically assigned,
	but sometimes the same port is used to both because they are different
	protocols (IPv4 and IPv6). In this case, their URIs are resolved to the
	completely same one (`druby://localhost:port`), which confuses the
	method `DRb.here?` which determines the DRbObject is remote or local.

	This changeset uses `druby://localhost:0` consistently.
	---
	 test/drb/test_drb.rb    | 4 ++--
	 test/drb/test_drbssl.rb | 2 +-
	 2 files changed, 3 insertions(+), 3 deletions(-)
2021-04-16 05:30:08 +09:00
nagachika 6847ee089d merge revision(s) 856a9701fd:
Get rid of multibyte prefix to tmpdir

	---
	 test/ruby/test_require.rb | 12 ++++++------
	 1 file changed, 6 insertions(+), 6 deletions(-)
2021-04-05 21:39:38 +09:00
nagachika 59cfa0b134 Backport a tmpdir fix.
Remove other then alphanumeric and some punctuations considered
filesystem-safe, instead of removing some unsafe chars only.
2021-04-05 20:48:25 +09:00
nagachika b59e5a64be Backport rexml upstream bug fixes. 2021-04-05 20:14:49 +09:00
nagachika 364c859588 merge revision(s) a85ed626f1: [Backport #17731]
Fix Enumerable#inject with high negative fixnums [Bug #17731]

	---
	 enum.c                 | 2 +-
	 test/ruby/test_enum.rb | 2 ++
	 2 files changed, 3 insertions(+), 1 deletion(-)
2021-03-20 16:16:45 +09:00
nagachika ec779aa56f merge revision(s) f748b911c9: [Backport #17729]
Fix infinite loop at illegal sequence [Bug #17729]

	As mblen returns -1 on failure, skip the first byte and try the
	succeeding bytes in that case.

	Close https://github.com/ruby/ruby/pull/4281
	---
	 eval_intern.h                 | 11 ++++++++++-
	 test/ruby/test_rubyoptions.rb |  5 +++++
	 2 files changed, 15 insertions(+), 1 deletion(-)
2021-03-20 16:15:35 +09:00
nagachika 6e962f02b2 merge revision(s) 58660e9434: [Backport #17519]
Skip refined method when exporting methods with changed visibility

	Previously, attempting to change the visibility of a method in a
	singleton class for a class/module that is prepended to and refined
	would raise a NoMethodError.

	Fixes [Bug #17519]
	---
	 test/ruby/test_module.rb | 23 +++++++++++++++++++++++
	 vm_method.c              | 14 +++++++++++---
	 2 files changed, 34 insertions(+), 3 deletions(-)
2021-03-20 16:14:18 +09:00
nagachika ce02265d59 merge revision(s) 0dc95266e8:
Fix the failing test with XDG_CONFIG_HOME

	---
	 test/irb/test_init.rb | 4 ++++
	 1 file changed, 4 insertions(+)
2021-03-20 16:04:02 +09:00
nagachika 82bce422ba merge revision(s) 254bed302752a401b5fcc3b6c65a9c93711d91d6,fad3023e94c45e7f03478732f7641b6f39ba9d12,3156fb0f2c3ebf8229f392c8502c08fe165ab181: [Backport #17218]
Renamed `nurat_sub` compliant with `rb_rational_plus`

	---
	 internal/rational.h | 1 +
	 rational.c          | 6 +++---
	 2 files changed, 4 insertions(+), 3 deletions(-)

	Fix ArithmeticSequence#last and ArithmeticSequence#each for
	 non-integer sequences (#3870)

	[Bug #17218]
	[ruby-core:100312]
	---
	 common.mk                             |  2 +
	 enumerator.c                          | 99 ++++++++++++++++++++++++++++++++---
	 internal/numeric.h                    |  2 +
	 internal/rational.h                   |  2 +
	 numeric.c                             | 53 ++++++++++---------
	 rational.c                            | 28 +++++++---
	 test/ruby/test_arithmetic_sequence.rb | 10 ++++
	 7 files changed, 156 insertions(+), 40 deletions(-)

	test/ruby/test_arithmetic_sequence.rb: remove a duplicated test

	There is another "test_last_bug17218"
	---
	 test/ruby/test_arithmetic_sequence.rb | 5 -----
	 1 file changed, 5 deletions(-)
2021-03-20 15:35:30 +09:00
nagachika c02f4c1c5a merge revision(s) e0dd072978e6c2c8180e75617e7ee37830caefa3,85f99f4b715a5954124d5014002c16652995b128:
Fix errors when XDG_CONFIG_HOME points to non-writable directory

	`$HOME/.config` is not writable on CI
	because I think tests should not corrupt user's data.

	And GitHub Actions CI sets `XDG_CONFIG_HOME`
	since `Version: 20210309.1`.

	https://github.com/ruby/actions/runs/2130811016?check_suite_focus=true#step:16:301
	```
	Errno::EACCES: Permission denied @ dir_s_mkdir - /home/runner/.config/irb
	```
	---
	 test/irb/test_cmd.rb | 2 ++
	 1 file changed, 2 insertions(+)

	Try to fix errors in TestIRB::TestHistory too

	https://github.com/ruby/actions/runs/2137935523?check_suite_focus=true#step:9:562
	```
	  1) Error:
	TestIRB::TestHistory#test_history_concurrent_use:
	Errno::EACCES: Permission denied @ dir_s_mkdir - /home/runner/.config/irb
	    /home/runner/work/actions/actions/ruby/lib/fileutils.rb:253:in `mkdir'
	    /home/runner/work/actions/actions/ruby/lib/fileutils.rb:253:in `fu_mkdir'
	    /home/runner/work/actions/actions/ruby/lib/fileutils.rb:231:in `block (2 levels) in mkdir_p'
	    /home/runner/work/actions/actions/ruby/lib/fileutils.rb:229:in `reverse_each'
	    /home/runner/work/actions/actions/ruby/lib/fileutils.rb:229:in `block in mkdir_p'
	    /home/runner/work/actions/actions/ruby/lib/fileutils.rb:211:in `each'
	    /home/runner/work/actions/actions/ruby/lib/fileutils.rb:211:in `mkdir_p'
	    /home/runner/work/actions/actions/ruby/lib/irb/init.rb:355:in `rc_file_generators'
	    /home/runner/work/actions/actions/ruby/lib/irb/init.rb:330:in `rc_file'
	    /home/runner/work/actions/actions/ruby/test/irb/test_history.rb:170:in `block in assert_history'
	    /home/runner/work/actions/actions/ruby/lib/tmpdir.rb:96:in `mktmpdir'
	    /home/runner/work/actions/actions/ruby/test/irb/test_history.rb:168:in `assert_history'
	    /home/runner/work/actions/actions/ruby/test/irb/test_history.rb:133:in `test_history_concurrent_use'
	```
	---
	 test/irb/test_history.rb | 2 ++
	 1 file changed, 2 insertions(+)
2021-03-20 15:01:48 +09:00
nagachika a859825539 merge revision(s) 276f6a225d18561cbe5282b798cb4e416c66079f,95bef7b69a6fb42687a6200b338060be307259f5: [Backport #17352]
Don't double fractional seconds when passing timezone object to
	 Time.new

	I found that fractional seconds were doubled when using the timezone
	feature of Time in Sequel's named_timezones extension (which uses
	TZInfo for the timezone object), and traced the problem to this code.

	There is no subsecx being modified in the utc_to_local call below
	this, and I'm not sure why you would want to add in the fractional
	seconds unless you assumed the timezone conversion would drop the
	existing fractional seconds (TZInfo doesn't drop fractional seconds).
	---
	 test/ruby/test_time_tz.rb | 10 ++++++++++
	 1 file changed, 10 insertions(+)

	Subsecond of Time::tm should be 0

	---
	 time.c | 1 +
	 1 file changed, 1 insertion(+)
2021-03-20 14:43:10 +09:00
nagachika 82d72f14e7 merge revision(s) ebb96fa880: [Backport #17321]
Fix singleton class cloning

	Before this commit, `clone` gave different results depending on whether the original object
	had an attached singleton class or not.

	Consider the following setup:
	```
	class Foo; end
	Foo.singleton_class.define_method(:foo) {}

	obj = Foo.new

	obj.singleton_class if $call_singleton

	clone = obj.clone
	```

	When `$call_singleton = false`, neither `obj.singleton_class.singleton_class` nor
	`clone.singleton_class.singleton_class` own any methods.

	However, when `$call_singleton = true`, `clone.singleton_class.singleton_class` would own a copy of
	`foo` from `Foo.singleton_class`, even though `obj.singleton_class.singleton_class` does not.

	The latter case is unexpected and results in a visibly different clone, depending on if the original object
	had an attached class or not.

	Co-authored-by: Ufuk Kayserilioglu <ufuk.kayserilioglu@shopify.com>
	---
	 class.c                 | 31 ++++++++++++++++++++++---------
	 test/ruby/test_class.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++++
	 2 files changed, 69 insertions(+), 9 deletions(-)
2021-03-20 14:26:30 +09:00
nagachika c98aa2db60 merge revision(s) c60aaed185: [Backport #17130]
Fix Method#super_method for aliased methods

	Previously, Method#super_method looked at the called_id to
	determine the method id to use, but that isn't correct for
	aliased methods, because the super target depends on the
	original method id, not the called_id.

	Additionally, aliases can reference methods defined in other
	classes and modules, and super lookup needs to start in the
	super of the defined class in such cases.

	This adds tests for Method#super_method for both types of
	aliases, one that uses VM_METHOD_TYPE_ALIAS and another that
	does not.  Both check that the results for calling super
	methods return the expected values.

	To find the defined class for alias methods, add an rb_ prefix
	to find_defined_class_by_owner in vm_insnhelper.c and make it
	non-static, so that it can be called from method_super_method
	in proc.c.

	This bug was original discovered while researching [Bug #11189].

	Fixes [Bug #17130]
	---
	 proc.c                   | 13 ++++++--
	 test/ruby/test_method.rb | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
	 vm_insnhelper.c          |  6 ++--
	 3 files changed, 94 insertions(+), 5 deletions(-)
2021-03-20 13:29:39 +09:00
nagachika 70c3a195f3 merge revision(s) 9682db0651: [Backport #12838] [Backport #17658]
Remove sender/message_id pair after response received in resolv

	Once a response for a given DNS request has been received (which
	requires a matching message id), the [sender, message_id] pair
	should be removed from the list of valid senders.  This makes it
	so duplicate responses from the same sender are ignored.

	Fixes [Bug #12838]
	---
	 lib/resolv.rb           |   2 +-
	 test/resolv/test_dns.rb | 113 ++++++++++++++++++++++++++++++++++++++++++++++++
	 2 files changed, 114 insertions(+), 1 deletion(-)
2021-03-20 13:18:32 +09:00
nagachika 190ffd8761 merge revision(s) f4be7a510eebbe6507ba41d138d7d252f4a68e90,9441f3f97087a4325ee80911859d37da41fa5050: [Backport #17504]
Added tests for Time#getlocal with UTC offset

	---
	 test/ruby/test_time.rb | 8 ++++++++
	 1 file changed, 8 insertions(+)

	Allow UTC offset without colons per ISO-8601 [Bug #17504]

	---
	 test/ruby/test_time.rb |  6 ++++++
	 time.c                 | 44 +++++++++++++++++++++++++++++---------------
	 2 files changed, 35 insertions(+), 15 deletions(-)
2021-02-27 13:46:28 +09:00