Commit graph

8209 commits

Author SHA1 Message Date
Peter Zhu
a5b6598192 [Feature #18239] Implement VWA for strings
This commit adds support for embedded strings with variable capacity and
uses Variable Width Allocation to allocate strings.
2021-10-25 13:26:23 -04:00
Yusuke Endoh
86e3d77abb
Make Coverage suspendable (#4856)
* Make Coverage suspendable

Add `Coverage.suspend`, `Coverage.resume` and some methods.

[Feature #18176] [ruby-core:105321]
2021-10-25 20:00:51 +09:00
Kazuki Yamaguchi
e10dfdf623 [ruby/openssl] bn: expand BIGNUM_RAND and BIGNUM_RAND_RANGE macros
Now that BN.pseudo_rand{,_range} are alias, those macros are only used
once. Let's expand the macros for better readability.

7c2fc00dee
2021-10-25 00:40:48 +09:00
Kazuki Yamaguchi
e19186707a [ruby/openssl] bn: make BN.pseudo_rand{,_range} an alias of BN.rand{,_range}
BN_pseudo_rand() and BN_pseudo_rand_range() are deprecated in
OpenSSL 3.0. Since they are identical to their non-'pseudo' version
anyway, let's make them alias.

2d34e85ddf
2021-10-25 00:40:48 +09:00
Kazuki Yamaguchi
1b5ccc8a0c [ruby/openssl] pkey, ssl: use EVP_PKEY_eq() instead of EVP_PKEY_cmp()
OpenSSL 3.0 renamed EVP_PKEY_cmp() to EVP_PKEY_eq() because that was a
confusing name.

d42bd7fcdb
2021-10-25 00:40:47 +09:00
Kazuki Yamaguchi
ee7131614c [ruby/openssl] pkey/ec: use EC_GROUP_free() instead of EC_GROUP_clear_free()
EC_GROUP_clear_free() is deprecated in OpenSSL 3.0.

EC_GROUP does not include any sensitive data, so we can safely use
EC_GROUP_free() instead.

e93a5fdffc
2021-10-25 00:40:47 +09:00
Kazuki Yamaguchi
555788b622 [ruby/openssl] pkey/ec: deprecate PKey::EC::Point#make_affine! and make it a no-op
It converts the internal representation of the point object to the
affine coordinate system. However, it had no real use case because the
difference in the internal representation has not been visible from
Ruby/OpenSSL at all.

EC_POINT_make_affine() is marked as deprecated in OpenSSL 3.0.

e2cc81fef7
2021-10-25 00:40:46 +09:00
Kazuki Yamaguchi
16272d9ae9 [ruby/openssl] hmac: use EVP_MD_CTX_get_pkey_ctx() instead of EVP_MD_CTX_pkey_ctx()
OpenSSL 3.0 renamed EVP_MD_CTX_pkey_ctx() to include "get" in the
function name. Adjust compatibility macro so that we can use the new
function name for all OpenSSL 1.0.2-3.0.

c106d888c6
2021-10-25 00:40:46 +09:00
Kazuki Yamaguchi
040387d265 [ruby/openssl] digest: use EVP_MD_CTX_get0_md() instead of EVP_MD_CTX_md() if exists
The function was renamed in OpenSSL 3.0 due to the change of the
lifetime of EVP_MD objects. They are no longer necessarily statically
allocated and can be reference-counted -- when an EVP_MD_CTX is free'd,
the associated EVP_MD can also become inaccessible.

Currently Ruby/OpenSSL only handles builtin algorithms, so no special
handling is needed except for adapting to the rename.

0a253027e6
2021-10-25 00:40:45 +09:00
Kazuki Yamaguchi
cfa4fa636e [ruby/openssl] bn: use BN_check_prime() in OpenSSL::BN#prime{,_fasttest}?
In OpenSSL 3.0, BN_is_prime_ex() and BN_is_prime_fasttest_ex() are
deprecated in favor of BN_check_prime().

90d51ef510
2021-10-25 00:40:45 +09:00
Kazuki Yamaguchi
fa24e7a57e [ruby/openssl] ssl: use SSL_get_rbio() to check if SSL is started or not
Use SSL_get_rbio() instead of SSL_get_fd(). SSL_get_fd() internally
calls SSL_get_rbio() and it's enough for our purpose.

In OpenSSL 3.0, SSL_get_fd() leaves an entry in the OpenSSL error queue
if BIO has not been set up yet, and we would have to clean it up.

e95ee24867
2021-10-25 00:40:44 +09:00
Kazuki Yamaguchi
d5aa3fcae6 [ruby/openssl] ssl: use SSL_CTX_load_verify_{file,dir}() if available
SSL_CTX_load_verify_locations() is deprecated in OpenSSL 3.0 and
replaced with those two separate functions. Use them if they exist.

5375a55ffc
2021-10-25 00:40:44 +09:00
Kazuki Yamaguchi
19ef7082ba [ruby/openssl] ts: use TS_VERIFY_CTX_set_certs instead of TS_VERIFY_CTS_set_certs
OpenSSL 3.0 fixed the typo in the function name and replaced the
current 'CTS' version with a macro.

2be6779b08
2021-10-25 00:40:43 +09:00
Kazuki Yamaguchi
3d16401508 [ruby/openssl] ossl.c: use ERR_get_error_all() if available
OpenSSL 3.0 deprecated ERR_get_error_line_data() in favor of
ERR_get_error_all(), as part of the error queue structure changes.

8e98d2ecc8
2021-10-25 00:40:43 +09:00
Kazuki Yamaguchi
32d49e93cf [ruby/openssl] ext/openssl/ossl.h: add helper macros for OpenSSL/LibreSSL versions
Add following convenient macros:

 - OSSL_IS_LIBRESSL
 - OSSL_OPENSSL_PREREQ(maj, min, pat)
 - OSSL_LIBRESSL_PREREQ(maj, min, pat)

00abee791d
2021-10-25 00:40:42 +09:00
Hiroshi SHIBATA
1be2875e1d
[flori/json] Bump version to v2.6.1
2db5894cfa
2021-10-24 09:25:20 +09:00
Josef Šimánek
4cbce79438
[flori/json] Bump JSON::VERSION to 2.6.0.
da94d9f059
2021-10-24 09:25:01 +09:00
David Rodríguez
d04d6bbc6c [ruby/psych] Prefer require_relative for internal requires
a0f55ee85a
2021-10-24 08:49:14 +09:00
Josef Šimánek
48cd633094 [ruby/psych] Add stringio as a dependency.
86e3049579
2021-10-24 08:48:40 +09:00
Sutou Kouhei
c0c43276a1 [ruby/strscan] Bump version
If we use the same version as the default strscan gem in Ruby, "gem
install" doesn't extract .gem. It fails "gem install" because "gem
install" can't find ext/strscan/ to be built.

3ceafa6cdc
2021-10-24 05:57:48 +09:00
Aaron Patterson
35b9d8d393 [ruby/openssl] Raise an exception if the IO object passed to SSLSocket isn't a file
SSLSocket#connect eventually calls `GetOpenFile` in order to get the
underlying file descriptor for the IO object passed in on
initialization.  `GetOpenFile` assumes that the Ruby object passed in is
a T_FILE object and just casts it to a T_FILE without any checks.  If
you pass an object that *isn't* a T_FILE to that function, the program
will segv.

Since we assume the IO object is a file in the `connect` method, this
commit adds a `CheckType` in the initialize method to ensure that the IO
object is actually a T_FILE.  If the object *isn't* a T_FILE, this class
will segv on `connect`, so I think this is a backwards compatible
change.

919fa44ec2
2021-10-23 13:38:40 +09:00
Hiroshi SHIBATA
93691d0752
Import bigdecimal-3.1.0.dev 2021-10-22 15:53:49 +09:00
Hiroshi SHIBATA
c5345979e8
Bump up readline-ext version to 0.1.3 2021-10-21 21:17:45 +09:00
Hiroshi SHIBATA
7529fe82f0 [ruby/io-wait] Bump up io-wait version to 0.2.0
f6a1b10a59
2021-10-21 20:54:20 +09:00
Hiroshi SHIBATA
8eb8522f47 [ruby/stringio] Bump up stringio version to 3.0.1
f7c40aa339
2021-10-21 20:53:53 +09:00
Hiroshi SHIBATA
5823168706 [ruby/psych] Bump up psych version to 4.0.2
69a713f860
2021-10-21 13:49:20 +09:00
Alan Wu
c02517bacb Tie lifetime of uJIT blocks to iseqs
* Tie lifetime of uJIT blocks to iseqs

   Blocks weren't being freed when iseqs are collected.

* Add rb_dary. Use it for method dependency table

* Keep track of blocks per iseq

  Remove global version_tbl

* Block version bookkeeping fix

* dary -> darray

* free ujit_blocks

* comment about size of ujit_blocks
2021-10-20 18:19:29 -04:00
Hiroshi SHIBATA
847eeafd65 [ruby/etc] Bump up etc version to 1.3.0
85ca541d0b
2021-10-19 20:55:33 +09:00
Hiroshi SHIBATA
b482a516d2 [ruby/zlib] Bump up zlib version to 2.1.1
82e9a636a6
2021-10-19 20:28:57 +09:00
Nobuyoshi Nakada
ae25313e80
[ruby/etc] Remove unnecessary declaration
Fix https://github.com/ruby/etc/pull/12

7cbf03d22d
2021-10-19 17:25:40 +09:00
Kazuki Yamaguchi
cc8ff8b50d [ruby/openssl] require Ruby 2.6 or later
Drop support for Ruby 2.3, 2.4, and 2.5.

As of 2021-10, Ruby 2.6 is the oldest version that still receives
security fixes from the Ruby core team, so it doesn't make much sense
to keep code for those ancient versions.

3436bd040d
2021-10-16 19:39:13 +09:00
Kazuki Yamaguchi
4991dabdd0 [ruby/openssl] bump version number to 3.0.0.pre
baa83a8a57
2021-10-16 18:57:57 +09:00
Kazuki Yamaguchi
cea3c55d58 [ruby/openssl] Ruby/OpenSSL 2.2.1
65e7207a07
2021-10-16 18:34:35 +09:00
Kazuki Yamaguchi
75e72baba1 [ruby/openssl] Ruby/OpenSSL 2.1.3
e8ee01b22c
2021-10-16 18:34:35 +09:00
Kazuki Yamaguchi
c1147f7f71 [ruby/openssl] ssl: avoid directly storing String object in NPN callback
On the server side, the serialized list of protocols is stored in
SSL_CTX as a String object reference. We utilize a hidden instance
variable to prevent it from being GC'ed, but this is not enough because
it can also be relocated by GC.compact.

5eb68ba778
2021-10-16 18:34:35 +09:00
Kazuki Yamaguchi
f6612203fa [ruby/openssl] x509store: explicitly call rb_gc_mark() against Store/StoreContext
We store the reverse reference to the Ruby object in the OpenSSL
struct for use from OpenSSL callback functions. To prevent the Ruby
object from being relocated by GC.compact, we must "pin" it by calling
rb_gc_mark().

a6ba9f894f
2021-10-16 18:34:35 +09:00
Kazuki Yamaguchi
ca28545b51 [ruby/openssl] ssl: explicitly call rb_gc_mark() against SSLContext/SSLSocket objects
We store the reverse reference to the Ruby object in the OpenSSL
struct for use from OpenSSL callback functions. To prevent the Ruby
object from being relocated by GC.compact, we must "pin" it by calling
rb_gc_mark().

022b7ceada
2021-10-16 18:34:35 +09:00
Kazuki Yamaguchi
c6c2190c4c [ruby/openssl] digest: load digest library using Kernel#require
The digest library is a default gem now, too. Therefore we can't simply
use rb_require() to load it, but we should use Kernel#require instead.

This change is based on the suggestion by David Rodríguez in
16172612d5 (commitcomment-57778397)

157f80794b
2021-10-16 18:34:35 +09:00
Nobuhiro IMAI
f88401f38e [ruby/openssl] fix segv in Timestamp::{Request,Response,TokenInfo}.new
prevent `ossl_ts_*_free()` from calling when `d2i_TS_*_bio()` failed.

b29e215786
2021-10-16 18:34:35 +09:00
David Carlier
6dcc74155f [ruby/openssl] ts: libressl build fix warning
TS_time_cb on libressl expects an long long/time_t 64 bits long instead.

4c99f577b2
2021-10-16 18:34:35 +09:00
Kazuki Yamaguchi
daeb914a52 [ruby/openssl] ssl: temporary lock string buffer while reading
Similarly to SSLSocket#syswrite, the blocking SSLSocket#sysread allows
context switches. We must prevent other threads from modifying the
string buffer.

We can use rb_str_locktmp() and rb_str_unlocktmp() to temporarily
prohibit modification of the string.

d38274949f
2021-10-16 18:34:35 +09:00
Kazuki Yamaguchi
5828807626 [ruby/openssl] ssl: create a temporary frozen string buffer when writing
Since a blocking SSLSocket#syswrite call allows context switches while
waiting for the underlying socket to be ready, we must freeze the string
buffer to prevent other threads from modifying it.

Reference: https://github.com/ruby/openssl/issues/452

aea874bc6e
2021-10-16 18:25:28 +09:00
Kazuki Yamaguchi
6105ef7629 [ruby/openssl] ssl: add SSLContext#tmp_dh=
Provide a wrapper of SSL_set0_tmp_dh_pkey()/SSL_CTX_set_tmp_dh(), which
sets the DH parameters used for ephemeral DH key exchange.

SSLContext#tmp_dh_callback= already exists for this purpose, as a
wrapper around SSL_CTX_set_tmp_dh_callback(), but it is considered
obsolete and the OpenSSL API is deprecated for future removal. There is
no practical use case where an application needs to use different DH
parameters nowadays. This was originally introduced to support export
grade ciphers.

RDoc for #tmp_dh_callback= is updated to recommend the new #tmp_dh=.

Note that current versions of OpenSSL support automatic ECDHE curve
selection which is enabled by default. SSLContext#tmp_dh= should only be
necessary if you must allow ancient clients which don't support ECDHE.

aa43da4f04
2021-10-16 18:19:52 +09:00
Kazuki Yamaguchi
49217086ad [ruby/openssl] ssl: remove private method SSLSocket#tmp_ecdh_callback
Commit ee037e146037 ("ssl: remove SSL::SSLContext#tmp_ecdh_callback",
2020-08-12) forgot to remove the method.

bef9ea84e4
2021-10-16 18:19:51 +09:00
Sutou Kouhei
027a3379d6 [ruby/zlib] Fix a bug that GZipReader#gets may return incomplete line
See also: https://github.com/ruby/csv/issues/117#issuecomment-933289373

How to reproduce with x.csv.gz in the issue comment:

    Zlib::GzipReader.open("x.csv.gz") do |rio|
      rio.gets(nil, 1024)
      while line = rio.gets(nil, 8192)
        raise line unless line.valid_encoding?
      end
    end

Reported by Dimitrij Denissenko. Thanks!!!

b1f182e98f
2021-10-15 15:31:15 +09:00
Nobuyoshi Nakada
e057b9eea9
Prefer the reentrant versions of gmtime and localtime 2021-10-14 23:44:15 +09:00
Hiroshi SHIBATA
2fa0d51ac9 [ruby/date] Bump up date version to 3.2.0
e0a4cbc8f6
2021-10-14 21:15:57 +09:00
Hiroshi SHIBATA
b7f557178d [ruby/pathname] Bump up pathname version to 0.2.0
e6b3b3ed25
2021-10-14 21:08:03 +09:00
Hiroshi SHIBATA
f88628014a [ruby/nkf] Bump up nkf version to 0.1.1
9aa7c6b841
2021-10-14 20:29:27 +09:00
Nobuyoshi Nakada
d210950196
[ruby/etc] Get rid of alloca in the loop
c989bacc4c
2021-10-14 18:44:27 +09:00