6470 Commits
Author SHA1 Message Date
NAKAMURA Usaku 1f4d455848 Fix previous commit 2023-03-30 21:34:08 +09:00
NAKAMURA Usaku 153bdddfc2 Limit header length 2023-03-30 20:08:27 +09:00
git 6439ebc476 * 2023-03-30 [ci skip] 2023-03-30 10:48:39 +00:00
git f95f5fda8a * 2023-03-29 [ci skip] 2023-03-29 01:17:36 +00: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
NAKAMURA Usaku d21f98531f Bump teeny 2022-12-08 12:33:42 +09:00
NAKAMURA Usaku 168ec2b1e5 Use %printer directive for Bison 3.8 (used release flow)
This is backport of fa05697e48
2022-11-24 21:42:08 +09:00
NAKAMURA Usaku 9eee81bcd0 Bump version 2022-11-24 19:42:05 +09:00
git ca07082a76 * 2022-11-24 [ci skip] 2022-11-24 02:21:03 +00:00
git 7b413c1db3 * 2022-10-01 [ci skip] 2022-10-01 15:59:05 +09:00
git 6b099328af * 2022-09-20 [ci skip] 2022-09-20 18:46:48 +09:00
git a62cfce75f * 2022-09-16 [ci skip] 2022-09-16 15:11:21 +09:00
NAKAMURA Usaku c9c2245c0a Fix dtoa buffer overrun 2022-04-12 20:25:48 +09:00
git 389723d854 * 2022-04-07 [ci skip] 2022-04-07 22:52:52 +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 2d886af0a5 merge revision(s) 6a6227e016: [Backport #18517]
Shifting zero always results in zero [Bug #18517]

	---
	 numeric.c | 2 ++
	 1 file changed, 2 insertions(+)
2022-03-19 22:27:18 +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 1034b6e7ba merge revision(s) 0c5f8c6276: [Backport #10961]
[ruby/zlib] Resume zstream if available [Bug #10961]

	---
	 ext/zlib/zlib.c | 6 ++++++
	 1 file changed, 6 insertions(+)
2021-12-31 19:48:36 +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 b829811131 merge revision(s) 43a3c88187: [Backport #18372]
[win32] get rid of redefinition of reserved macro

	```
	warning C4117: macro name '_INTEGRAL_MAX_BITS' is reserved, '#define' ignored
	```
	---
	 win32/Makefile.sub | 2 ++
	 1 file changed, 2 insertions(+)
2021-12-31 19:48:13 +09:00
NAKAMURA Usaku c24f436c2a merge revision(s) 9f8a50723f: [Backport #17836]
Specify -c to emit pch with clang (#4423)

	[Bug #17836]
	---
	 mjit_worker.c | 1 +
	 1 file changed, 1 insertion(+)
2021-12-31 19:47:57 +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
NAKAMURA Usaku 0fd9588395 merge revision(s) d795f494a8: [Backport #17794]
Avoid `free(3)`ing invalid pointer

	Fixes [Bug #17794]
	---
	 addr2line.c | 2 ++
	 1 file changed, 2 insertions(+)
2021-11-24 19:31:06 +09:00
NAKAMURA Usaku f236548038 merge revision(s) 345db8f2aa: [Backport #10902]
Avoid pointless attempts to open .so file if already required

	When attempting to require a file without an extension that has
	already been required or provided with an .so extension, only
	look for files with an .rb extension. There is no point in
	trying to find files with an .so extension, since we already
	know one has been loaded.

	Previously, attempting to require such a file scanned the load
	path twice, once for .rb and once for .so.  Now it only scans
	once for .rb.  The scan once for .rb cannot be avoided, since
	the .rb file would take precedence and should be loaded if it
	exists.

	Fixes [Bug #10902]
	---
	 load.c | 7 ++++++-
	 1 file changed, 6 insertions(+), 1 deletion(-)
2021-11-24 19:27:06 +09:00
NAKAMURA Usaku 7d4d38f883 merge revision(s) b360588cd3: [Backport #15856]
Sort feature index arrays by the priority of file types [Bug #15856]

	When looking for libraries to load with a feature name without
	extension, `.rb` files are given priority. However, since the
	feature index arrays were not in that order of priority, but in
	the order in which they were loaded, a lower priority extension
	library might be returned. In that case, the `.rb` file had to be
	searched for again from the `$LOAD_PATH`, resulting in poor
	performance.
	---
	 load.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-------
	 1 file changed, 45 insertions(+), 7 deletions(-)
2021-11-24 19:26:29 +09:00
NAKAMURA Usaku 6601fb5672 merge revision(s) 25e56fe374478a2266ac25f22a07bb3c6a423c83,8758b07b1e4fd636dffb4b442388a3033c63d4b5,791e8eec66d3aebcee36c1369b0bf52bc3815e94: [Backport #18016]
[ruby/fiddle] Fix Win32Types for Windows 64-bit (#63)

	https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types

	https://github.com/ruby/fiddle/commit/28ee5b1608
	---
	 ext/fiddle/lib/fiddle/types.rb | 8 ++++----
	 1 file changed, 4 insertions(+), 4 deletions(-)

	[ruby/fiddle] Fix more Win32Types definitions

	https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types

	https://github.com/ruby/fiddle/commit/805c1a595a
	---
	 ext/fiddle/lib/fiddle/types.rb | 23 ++++++++++++-----------
	 1 file changed, 12 insertions(+), 11 deletions(-)

	[ruby/fiddle] win32types: sort

	https://github.com/ruby/fiddle/commit/35dec6c5a5
	---
	 ext/fiddle/lib/fiddle/types.rb | 30 +++++++++++++++---------------
	 1 file changed, 15 insertions(+), 15 deletions(-)
2021-11-24 19:25:38 +09:00
git 7c6b56801e * 2021-11-24 [ci skip] 2021-11-24 16:10:47 +09:00
NAKAMURA Usaku ac7c2754c0 merge revision(s) b8386f7f7f [Backport #18161]
Prepend DebugSystem to VCS class only

    And revert 24e5f1c982, pepending to
    Kernel did not affect the top level methods before 3.0.
2021-09-19 19:43:12 +09:00
git 4b371d6ab2 * 2021-07-31 [ci skip] 2021-07-31 21:25:04 +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 87d02eacd2 merge revision(s) 9edc162583: [Backport #17781]
[ruby/resolv] Fix confusion of received response message

	This is a follow up for commit 33fb966197f1 ("Remove sender/message_id
	pair after response received in resolv", 2020-09-11).

	As the @senders instance variable is also used for tracking transaction
	ID allocation, simply removing an entry without releasing the ID would
	eventually deplete the ID space and cause
	Resolv::DNS.allocate_request_id to hang.

	It seems the intention of the code was to check that the received DNS
	message is actually the response for the question made within the method
	earlier. Let's have it actually do so.

	[Bug #12838] https://bugs.ruby-lang.org/issues/12838
	[Bug #17748] https://bugs.ruby-lang.org/issues/17748

	https://github.com/ruby/resolv/commit/53ca9c9209
	---
	 lib/resolv.rb | 6 +++---
	 1 file changed, 3 insertions(+), 3 deletions(-)
2021-06-02 01:40:08 +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 d8bbbc308e bump patchlevel for previous merge commit 2021-05-31 23:10:35 +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