Commit graph

15017 commits

Author SHA1 Message Date
Kazuki Yamaguchi
1e3590fe22 [ruby/openssl] pkey: add PKey.generate_parameters and .generate_key
Add two methods to create a PKey using the generic EVP interface. This
is useful for the PKey types we don't have a dedicated class.

d8e8e57de9
2021-03-16 19:16:11 +09:00
Kazuki Yamaguchi
d60ab95398 [ruby/openssl] test/openssl/test_ssl: fix flaky test case
Fix test_socket_open_with_local_address_port_context.

Often with MinGW, it seems EACCES is returned on bind when the port
number is unavailable. Ignore it just as we do for EADDRINUSE and
continue searching free port number.

Fixes: 98f8787b4687 ("test/openssl/test_ssl: fix random failure in
SSLSocket.open test", 2020-02-17)

413b15526e
2021-03-16 19:16:11 +09:00
Kazuki Yamaguchi
efad0166c6 [ruby/openssl] pkey: have PKey.read parse PEM-encoded DHParameter
Try PEM_read_bio_Parameters(). Only PEM format is supported at the
moment since corresponding d2i_* functions are not provided by OpenSSL.

867e5c021b
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
22aeb6373e [ruby/openssl] config: revert to C implementation of OpenSSL::Config
Revert OpenSSL::Config to using the OpenSSL API and remove our own
parser implementation for the config file syntax.

OpenSSL::Config now wraps a CONF object. Accessor methods deal with the
object directly rather than Ruby-level internal state.

This work is based on the old C code we used before 2010.

c891e0ea89
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
7c13d2b3cc [ruby/openssl] test/openssl/test_config: skip test_get_value_ENV on LibreSSL
LibreSSL has removed the feature to map environment variables onto the
"ENV" section.

b70817faec
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
0c66784602 [ruby/openssl] test/openssl/test_config: fix non-deterministic test case
Sort keys of a section before comparing. The ordering is not part of the
API. This can cause a test failure if we use OpenSSL's C implementation.

Fixes: 2ad65b5f673f ("config: support .include directive", 2018-08-16)

259e6fd2dc
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
ffc01afc47 [ruby/openssl] test/openssl/test_config: add missing test case for Config.parse_config
9ce2ccf36d
2021-03-16 19:16:10 +09:00
Kazuki Yamaguchi
67f5847c61 [ruby/openssl] config: remove deprecated methods
Remove 4 deprecated methods.

The following two methods have been marked as deprecated since 2003,
by r4531 (ruby.git commit 78ff3833fb).

 - OpenSSL::Config#value
 - OpenSSL::Config#section

Other two methods are removed because the corresponding functions
disappeared in OpenSSL 1.1.0.

 - OpenSSL::Config#add_value
 - OpenSSL::Config#[]=

9783d7f21c
2021-03-16 19:16:10 +09:00
Spencer McIntyre
4d8bce227c [ruby/openssl] Define Cipher #ccm_data_len= for CCM mode ciphers
Allow specifying just length to #update

CCM mode ciphers need to specify the total plaintext or ciphertext
length to EVP_CipherUpdate.

Update the link to the tests file

Define Cipher#ccm_data_len= for CCM mode ciphers

Add a unit test for CCM mode

Also check CCM is authenticated when testing

bb3816953b
2021-03-16 19:16:10 +09:00
aycabta
61a29a41e1 [ruby/rdoc] Allow empty .rdoc_options
0c8cb25b50
2021-03-16 15:47:27 +09:00
aycabta
971a0cd246 [ruby/rdoc] Allow partial default values to be overridden with .rdoc_options
e14800891f
2021-03-16 15:47:27 +09:00
Nobuyoshi Nakada
de8e6218a3 [ruby/rdoc] Fixed CodeFence without blank lines
Currently a fenced code block needs a preceding blank line, it
should not be required, as:
https://github.github.com/gfm/#fenced-code-blocks
> A fenced code block may interrupt a paragraph, and does not
> require a blank line either before or after.

Just recommended:
https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks
> We recommend placing a blank line before and after code blocks
> to make the raw formatting easier to read.

0e1776caf3
2021-03-16 15:47:27 +09:00
Nobuyoshi Nakada
3651f678a7 [ruby/rdoc] Support GFM table
9dc933df16
2021-03-16 15:47:27 +09:00
Nobuyoshi Nakada
82b6f89283 File.dirname optional level
* file.c (rb_file_dirname_n): chomp N level of base names.
  [Feature #12194]
2021-03-15 15:09:05 +09:00
xtkoba (Tee KOBAYASHI)
0846c2da45
Check backref number buffer overrun [Bug #16376] 2021-03-15 10:17:50 +09:00
Jeremy Evans
aaab3b1de9 Fix integer/float remainder with infinity argument of opposite sign
Previously, the result was incorrect:

4.remainder(-Float::INFINITY)
Before: => NaN
After: => 4

4.2.remainder(-Float::INFINITY)
Before: => NaN
After: => 4.2

Fixes [Bug #6120]
2021-03-12 07:35:18 -08:00
Nobuyoshi Nakada
a6b5d70bca
Create the test file under the created temporary directory
Fixes https://github.com/ruby/ruby/pull/4255
2021-03-11 09:21:21 +09:00
Jeremy Evans
d9fea496af Remove cvar overtaken classes at end of test methods
Fixes issues when the same tests are executed more than once,
which some CI machines do.
2021-03-10 12:09:45 -08:00
eileencodes
cbc7c1c061 Add cvar overtaken tests
While working on another project we noticed that there were no tests for
the cvar overtaken exception when using classes. This change adds a test
for cvar overtaken with classes and moves the cvar overtaken test for
modules into the new file.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-03-10 09:40:00 -08:00
Yusuke Endoh
d10b535806 test/ruby/test_string.rb: make GitHub syntax-highlight correctly
It looks like GitHub syntax-highlighting does not support an empty
heredoc. This change adds a newline to make GitHub can handle the syntax
appropriately.

https://bugs.ruby-lang.org/issues/17662
2021-03-08 17:04:27 +09:00
Aditya Prakash
7de349bb49 [rubygems/rubygems] Remote test to check require
This test was triggering require of `rubygems/core_ext/tcpsocket_init`
which overrides TCPSocket.initialize globally. Requires don't get
reset between test runs and it was making other test unreliable.

Fixes timeout of test on ruby master

fdfe5c9691
2021-03-08 13:47:35 +09:00
David Rodríguez
53468cc111 Sync latest development version of bundler & rubygems 2021-03-08 13:47:35 +09:00
Nobuyoshi Nakada
32a13591e0
[ruby/stringio] Check if closed in loop
[Bug #17675] https://bugs.ruby-lang.org/issues/17675

1ed61d0cbc
2021-03-08 10:13:29 +09:00
Nobuyoshi Nakada
d0a05fd4b4
Fixed FD leaks 2021-03-08 10:08:40 +09:00
Hiroshi SHIBATA
c3c1800708
Prefer to use omit 2021-03-08 09:34:16 +09:00
Nobuyoshi Nakada
f6d5de8f33 [ruby/io-wait] Declare as Ractor-safe
Fixes https://bugs.ruby-lang.org/issues/17659

ba338b4764
2021-03-07 09:54:35 +09:00
Nobuyoshi Nakada
ef9bde6516 [ruby/io-wait] Refined uncommon device type tests
0c73ebcf5d
2021-03-07 09:54:35 +09:00
Jeremy Evans
68d028578a Undef Enumerator::Chain#{feed,next,next_values,peek,peek_values}
Previously these methods were defined but raised TypeError, which
seems worse.
2021-03-06 13:56:16 -08:00
Jeremy Evans
e1d16a9e56 Make Enumerator#{+,chain} create lazy chain if any included enumerator is lazy
Implements [Feature #17347]
2021-03-06 13:56:16 -08:00
Jeremy Evans
bf40fe9fed Fix calling enumerator methods such as with_index on Enumerator::Chain
This previously raised a TypeError.  Wrap the Enumerator::Chain in
an Enumerator to work around the problem.

Fixes [Bug #17216]
2021-03-06 13:56:16 -08:00
Jeremy Evans
14e1739ff3 [ruby/irb] Make save-history extension safe for concurrent use
This makes the save-history extension check for modifications to
the history file before saving it.  If the history file was modified
after the history was loaded and before it was saved, append only
the new history lines to the history file.

This can result in more lines in the history file than SAVE_HISTORY
allows.  However, that will be fixed the next time irb is run and
the history is saved.

Fixes [Bug #13654]

041ef53845
2021-03-06 00:18:32 +09:00
aycabta
182cde8dfb [ruby/irb] Add a test for not continuing when endless range at eol
1020ac9c65
2021-03-05 22:03:11 +09:00
Aaron Patterson
d45466dc5b
Oops! Add another test and fix to_proc implementation 2021-02-26 10:06:56 -08:00
Aaron Patterson
0590e9b677
Fiddle::Function responds to to_proc
This lets us cast a Fiddle::Function to a block, allowing is to write
things like:

```ruby
f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
define_method :strcpy, &f
```
2021-02-26 09:57:13 -08:00
Aaron Patterson
cfc23903df
Revert "Add tests for bug 17652"
This reverts commit a9920e7782.
2021-02-25 16:31:24 -08:00
Peter Zhu
a9920e7782 Add tests for bug 17652 2021-02-25 11:01:50 -08:00
Aaron Patterson
08d5db4064
Reverting PR #4221
It seems this breaks tests on Solaris, so I'm reverting it until we
figure out the right fix.

  20210224T210007Z.fail.html.gz
2021-02-24 13:44:10 -08:00
Peter Zhu
59fb5d4fa3 Add tests for bug 17652 2021-02-24 12:25:30 -08:00
Andrew Aladjev
0d76636117 added mutexes for socket and connection lists on win32 2021-02-23 16:20:01 +09:00
Alan Wu
58e8220605 Check for cyclic prepend before making origin
It's important to only make the origin when the prepend goes
through, as the precense of the origin informs whether to do an
origin backfill.

This plus 2d877327e fix [Bug #17590].
2021-02-22 17:57:47 -05:00
nicholas a. evans
3ee4fa9491
Send :fiber_switch event for almost every fiber_switch (#4207)
With this patch, TracePoint receives a `:fiber_switch` event for
_almost_ every fiber switch.  Previously, it would not be sent when an
exception was going to be raised. Now the event should only be blockable
by an interrupt (including `Thread#raise`) or a fatal error.

Additionally, interrupts will now be checked on the return fiber
_before_ re-raising the terminating unhandled exception.  And a fiber
that terminates with an unhandled exception no longer creates a pending
interrupt on its thread.  The exception will be raised in the return
fiber the same way as `Fiber#raise`: using `cont.value` with `cont.argc
== -1`

I moved `rb_exc_raise` from `fiber_store` to the end of `fiber_switch`
after _all_ of the other cleanup code: `fiber_stack_release`,
`th->blocking` increment, `RUBY_VM_CHECK_INTS`, and `EXEC_EVENT_HOOK`.
It seems to me that skipping those other cleanup steps may have also
resulted in other bugs.
2021-02-22 10:33:11 +13:00
aycabta
7aa3bc8403 [ruby/reline] Add a test for suppressing crash when dynamic prompt returns empty
ref. https://github.com/ruby/reline/pull/262

b98bc3c329
2021-02-21 06:43:31 +09:00
aycabta
a3055a35dd [ruby/reline] Move script files for yamatanooroti tests
03031b885d
2021-02-21 06:41:56 +09:00
aycabta
dc9e33016c [ruby/reline] Return 1 when char width not found
This fixes ruby/reline#261.

3cf1213014
2021-02-21 06:41:03 +09:00
Jeremy Evans
cfd162d535 Make String#{strip,lstrip}{,!} strip leading NUL bytes
The documentation already specifies that they strip whitespace
and defines whitespace to include null.

This wraps the new behavior in the appropriate guards in the specs,
but does not specify behavior for previous versions, because this
is a bug that could be backported.

Fixes [Bug #17467]
2021-02-20 11:17:47 +09:00
Jeremy Evans
8743732621 Fix backtrace to not skip frames with iseq without pc
Previously, frames with iseq but no pc were skipped (even before
the refactoring in 3b24b7914c).
Because the entire backtrace was procesed before the refactoring,
this was handled by using later frames instead.  However, after
the refactoring, we need to handle those frames or they get
lost.

Keep two iteration counters when iterating, one for the desired
backtrace size (so we generate the desired number of frames), and
one for the actual backtrace size (so we don't process off the end
of the stack).  When skipping over an iseq frame with no pc,
decrement the counter for the desired backtrace, so it will
continue to process the expected number of backtrace frames.

Fixes [Bug #17581]
2021-02-19 08:14:24 -08:00
Shugo Maeda
a319c04818
Fix typo [ci skip] 2021-02-19 17:27:53 +09:00
Koichi Sasada
9c769575bf invalidate negative cache any time.
negative cache on a class which does not have subclasses was not
invalidated, but it should be invalidated because other classes
can cache this negative cache.
[Bug #17553]
2021-02-19 16:54:31 +09:00
Shugo Maeda
5de38c41ae
ripper: fix a bug of Ripper::Lexer with syntax error and heredoc [Bug #17644] 2021-02-19 16:40:29 +09:00
Nobuyoshi Nakada
9110021fd2 [ruby/readline-ext] Use omit
f6dff0a9f6
2021-02-18 21:17:42 +09:00