Граф коммитов

8482 Коммитов

Автор SHA1 Сообщение Дата
BurdetteLamar 0c63aa11bc
[ruby/bigdecimal] Set rounding mode in example
https://github.com/ruby/bigdecimal/commit/8fc83dd2fe
2021-12-24 02:28:58 +09:00
BurdetteLamar a8243d07e1
[ruby/bigdecimal] Set rounding mode in example
https://github.com/ruby/bigdecimal/commit/42c999f728
2021-12-24 02:28:57 +09:00
BurdetteLamar de5c14d4d8
[ruby/bigdecimal] Enhanced RDoc for selected methods
https://github.com/ruby/bigdecimal/commit/0de9298d15
2021-12-24 02:28:57 +09:00
BurdetteLamar e043829a7f
[ruby/bigdecimal] Enhanced RDoc for selected methods
https://github.com/ruby/bigdecimal/commit/6139ea1092
2021-12-24 02:28:57 +09:00
Kenta Murata d905abb457
[ruby/bigdecimal] Fix BigDecimal#precision for single DECDIG case
Fix GH-205

https://github.com/ruby/bigdecimal/commit/7d198394a2
2021-12-24 02:28:56 +09:00
Kenta Murata 38e98cbdb7
[ruby/bigdecimal] Keep obj-to-Real link when VpReallocReal returns different pointer
https://github.com/ruby/bigdecimal/commit/252748de17
2021-12-24 02:28:56 +09:00
Kenta Murata 75f552e973
[ruby/bigdecimal] Fix the precision of the adjusted quotient
https://github.com/ruby/bigdecimal/commit/8dc8cd339d
2021-12-24 02:28:56 +09:00
Kenta Murata 7b2cfce543
[ruby/bigdecimal] Let BigDecimal_DoDivmod use the same precision calculation as BigDecimal_divide
https://github.com/ruby/bigdecimal/commit/11cb2c8840
2021-12-24 02:28:55 +09:00
Kenta Murata e1265c8198
[ruby/bigdecimal] Use larger precision in divide for irrational or recurring results
Just in case for irrational or recurring results, the precision of the
quotient is set to at least more than 2*Float::DIG plus alpha.

[Bug #13754] [Fix GH-94]

https://github.com/ruby/bigdecimal/commit/99442c75d3
2021-12-24 02:28:55 +09:00
Kenta Murata 8ee8ac6423
[ruby/bigdecimal] Fix trailing zeros handling in rb_uint64_convert_to_BigDecimal
Fix GH-192

https://github.com/ruby/bigdecimal/commit/eebc98b85a
2021-12-24 02:28:55 +09:00
BurdetteLamar ed7f4c24d7
[ruby/bigdecimal] Respond to review
https://github.com/ruby/bigdecimal/commit/f528a0006e
2021-12-24 02:28:54 +09:00
BurdetteLamar ed8ec5dcb3
[ruby/bigdecimal] Respond to review
https://github.com/ruby/bigdecimal/commit/4eadcdf0a6
2021-12-24 02:28:54 +09:00
BurdetteLamar 44acab76af
[ruby/bigdecimal] Respond to review
https://github.com/ruby/bigdecimal/commit/6d69422e37
2021-12-24 02:28:53 +09:00
BurdetteLamar 973e508472
[ruby/bigdecimal] Respond to review for #precision
https://github.com/ruby/bigdecimal/commit/681cd2d81d
2021-12-24 02:28:53 +09:00
BurdetteLamar 5888d3030d
[ruby/bigdecimal] Enhanced RDoc for bigdecimal.c
https://github.com/ruby/bigdecimal/commit/3a35f92f8b
2021-12-24 02:28:53 +09:00
BurdetteLamar 01b2ccaa95
[ruby/bigdecimal] Enhanced RDoc for bigdecimal.c
https://github.com/ruby/bigdecimal/commit/31a7a37426
2021-12-24 02:28:52 +09:00
Jean Boussier ec478d947f
[ruby/bigdecimal] Fix negative Bignum conversion
Introduced in https://github.com/ruby/bigdecimal/commit/4792a917d806

`rb_absint_size` return the number of bytes needed to fit
the absolute integer, but negative integers need the sign, so one more
bit, and potentially one more byte.

https://github.com/ruby/bigdecimal/commit/0f3d5d0eb7
2021-12-24 02:28:51 +09:00
Olle Jonsson 03507498b6
[ruby/bigdecimal] VpCheckException: improve grammar
I added a space before the parenthesis, too.

https://github.com/ruby/bigdecimal/commit/159af10b17
2021-12-24 02:28:47 +09:00
Nobuyoshi Nakada 40a1af6151
Install ruby/digest.h when from ext/digest 2021-12-23 20:12:45 +09:00
Kazuki Yamaguchi ac757b218c [ruby/openssl] pkey: use EVP_PKEY_CTX_new_from_name() on OpenSSL 3.0
Replace EVP_PKEY_CTX_new_id() with the new EVP_PKEY_CTX_new_from_name()
which takes the algorithm name in a string instead of in an NID.

https://github.com/ruby/openssl/commit/d6535d13d1
2021-12-20 23:42:04 +09:00
Kazuki Yamaguchi 61e426ae05 [ruby/openssl] pkey: assume a pkey always has public key components on OpenSSL 3.0
OpenSSL 3.0's EVP_PKEY_get0() returns NULL for provider-backed pkeys.
This causes segfault because it was supposed to never return NULL
before.

We can't check the existence of public key components in this way on
OpenSSL 3.0. Let's just skip it for now.

https://github.com/ruby/openssl/commit/ccdb6f7bfa
2021-12-20 23:42:04 +09:00
Kazuki Yamaguchi 0b3482c0e7 [ruby/openssl] ssl: add constants for new SSL_OP_* flags
Add all SSL_OP_* constants defined in OpenSSL 3.0.0 which are not
specific to DTLS.

https://github.com/ruby/openssl/commit/b1ee2f23b2
2021-12-20 23:42:03 +09:00
Kazuki Yamaguchi b2fb503dab [ruby/openssl] engine: disable OpenSSL::Engine on OpenSSL 3.0
The entire ENGINE API is deprecated in OpenSSL 3.0 in favor of the new
"Provider" concept.

OpenSSL::Engine will not be defined when compiled with OpenSSL 3.0.
We would need a way to interact with providers from Ruby programs, but
since the concept is completely different from the ENGINE API, it will
not be through the current OpenSSL::Engine interface.

https://github.com/ruby/openssl/commit/69a27d8de4
2021-12-20 23:42:03 +09:00
Kazuki Yamaguchi c1a7c6df18 [ruby/openssl] hmac: fix wrong usage of EVP_DigestSignFinal()
According to the manpage, the "siglen" parameter must be initialized
beforehand.

https://github.com/ruby/openssl/commit/6a60c7b2e7
2021-12-20 23:42:02 +09:00
Kazuki Yamaguchi 8ebf597885 [ruby/openssl] pkey: deprecate PKey#set_* methods
OpenSSL 3.0 made EVP_PKEY immutable. This means we can only have a const
pointer of the low level struct and the following methods can no longer
be provided when linked against OpenSSL 3.0:

 - OpenSSL::PKey::RSA#set_key
 - OpenSSL::PKey::RSA#set_factors
 - OpenSSL::PKey::RSA#set_crt_params
 - OpenSSL::PKey::DSA#set_pqg
 - OpenSSL::PKey::DSA#set_key
 - OpenSSL::PKey::DH#set_pqg
 - OpenSSL::PKey::DH#set_key
 - OpenSSL::PKey::EC#group=
 - OpenSSL::PKey::EC#private_key=
 - OpenSSL::PKey::EC#public_key=

There is no direct replacement for this functionality at the moment.
I plan to introduce a wrapper around EVP_PKEY_fromdata(), which takes
all key components at once to construct an EVP_PKEY.

https://github.com/ruby/openssl/commit/6848d2d969
2021-12-20 23:42:02 +09:00
Kazuki Yamaguchi b93ae54258 [ruby/openssl] pkey/ec: deprecate OpenSSL::PKey::EC#generate_key!
OpenSSL::PKey::EC#generate_key! will not work on OpenSSL 3.0 because
keys are made immutable. Users should use OpenSSL::PKey.generate_key
instead.

https://github.com/ruby/openssl/commit/5e2e66cce8
2021-12-20 23:42:02 +09:00
Kazuki Yamaguchi 0d698be04f [ruby/openssl] pkey/dh: deprecate OpenSSL::PKey::DH#generate_key!
OpenSSL::PKey::DH#generate_key! will not work on OpenSSL 3.0 because
keys are made immutable. Users should use OpenSSL::PKey.generate_key
instead.

https://github.com/ruby/openssl/commit/8ee6a582c7
2021-12-20 23:42:02 +09:00
Kazuki Yamaguchi 50b90c5fc3 [ruby/openssl] pkey/ec: avoid using EC#public_key= in EC#dh_compute_key
Similarly to DH#compute_key, work around it by constructing a
SubjectPublicKeyInfo. This should be considered as a temporary
implementation.

https://github.com/ruby/openssl/commit/fc9aabc18d
2021-12-20 23:42:01 +09:00
Kazuki Yamaguchi dc3f37c6cc [ruby/openssl] pkey/dh: avoid using DH#set_key in DH#compute_key
DH#set_key will not work on OpenSSL 3.0 because keys are immutable.
For now, let's reimplement DH#compute_key by manually constructing a
DER-encoded SubjectPublicKeyInfo structure and feeding it to
OpenSSL::PKey.read.

Eventually, we should implement a new method around EVP_PKEY_fromdata()
and use it instead.

https://github.com/ruby/openssl/commit/46ca47060c
2021-12-20 23:42:01 +09:00
Kazuki Yamaguchi df6589e418 [ruby/openssl] pkey: use EVP_PKEY_dup() if available
We can use it to implement OpenSSL::PKey::PKey#initialize_copy. This
should work on all key types, not just DH/DSA/EC/RSA types.

https://github.com/ruby/openssl/commit/66cd8cbaaf
2021-12-20 23:42:01 +09:00
Kazuki Yamaguchi c1a36ebfda [ruby/openssl] pkey: allocate EVP_PKEY on #initialize
Allocate an EVP_PKEY when the content is ready: when #initialize
or #initialize_copy is called, rather than when a T_DATA is allocated.
This is more natural because the lower level API has been deprecated
and an EVP_PKEY is becoming the minimum unit of handling keys.

https://github.com/ruby/openssl/commit/74f6c61756
2021-12-20 23:42:01 +09:00
Kazuki Yamaguchi 02a58fbfd1 [ruby/openssl] pkey: do not check NULL argument in ossl_pkey_new()
Passing NULL to ossl_pkey_new() makes no sense in the first place, and
in fact it is ensured not to be NULL in all cases.

https://github.com/ruby/openssl/commit/316cb2a41f
2021-12-20 23:42:00 +09:00
Kazuki Yamaguchi 6ef0f272eb [ruby/openssl] pkey: use OSSL_DECODER to load encrypted PEM on OpenSSL 3.0
OpenSSL 3.0 has rewritten routines to load pkeys (PEM_read_bio_* and
d2i_* functions) around the newly introduced OSSL_DECODER API.

This comes with a slight behavior change. They now decrypt and parse
each encountered PEM block, then check the kind of the block. This used
to be the reverse: they checked the PEM header to see the kind, and then
decrypted the content. This means that the password callback may now be
called repeatedly.

Let's use the OSSL_DECODER API directly on OpenSSL 3.0 so that the
return value from the password callback will be reused automatically.

https://github.com/ruby/openssl/commit/a84ea531bb
2021-12-20 23:42:00 +09:00
Hiroshi SHIBATA 87b968c903
[ruby/psych] psych depends stringio only CRuby
https://github.com/ruby/psych/commit/e7bbf26cb2
2021-12-20 18:26:58 +09:00
Hiroshi SHIBATA 706c7a27fa [ruby/psych] Bump version to 4.0.3
https://github.com/ruby/psych/commit/75ab76e788
2021-12-20 18:25:50 +09:00
Nobuyoshi Nakada 54f0e63a8c Remove `NODE_DASGN_CURR` [Feature #18406]
This `NODE` type was used in pre-YARV implementation, to improve
the performance of assignment to dynamic local variable defined at
the innermost scope.  It has no longer any actual difference with
`NODE_DASGN`, except for the node dump.
2021-12-13 12:53:03 +09:00
Nobuyoshi Nakada e4b35b158a [ruby/cgi] Check integer overflow in long range
https://hackerone.com/reports/1328463

https://github.com/ruby/cgi/commit/ccaf6027e0
2021-12-12 13:05:15 +09:00
Hiroshi SHIBATA c41751f10e
[ruby/io-wait] Bump up 0.2.1
https://github.com/ruby/io-wait/commit/c97ab9a212
2021-12-09 19:28:54 +09:00
Yusuke Endoh 17e7219679 ext/ripper/lib/ripper/lexer.rb: Do not deprecate Ripper::Lexer::State#[]
The old code of IRB still uses this method. The warning is noisy on
rails console.
In principle, Ruby 3.1 deprecates nothing, so let's avoid the
deprecation for the while.
I think It is not so hard to continue to maintain it as it is a trivial
shim.

https://github.com/ruby/ruby/pull/5093
2021-12-09 00:30:17 +09:00
Peter Zhu 9f0c6f20c5 [Bug #18382] Fix crash in compaction for ObjectSpace.trace_object_allocations
ObjectSpace.trace_object_allocations can crash when auto-compaction is
enabled.
2021-12-02 13:06:44 -05:00
Nobuyoshi Nakada 524a808d23
Define Ripper::Lexer::Elem#to_s
Alias `#inspect` as `#to_s` also in the new `Ripper::Lexer::Elem`
class, so that `puts Ripper::Lexer.new(code).scan` shows the
attributes.
2021-12-02 18:29:45 +09:00
schneems 8944009be7 Deprecate `Lexer::Elem#[]` and `Lexer::State#[]`
Discussed in https://github.com/ruby/ruby/pull/5093#issuecomment-964426481. 

> it would be enough to mimic only [] for almost all cases

This adds back the `Lexer::Elem#[]` and `Lexer::State#[]` and adds deprecation warnings for them.
2021-12-02 15:55:42 +09:00
schneems 3685b5af95 Only iterate Lexer heredoc arrays
The last element in the `@buf` may be either an array or an `Elem`. In the case it is an `Elem` we iterate over every element, when we do not need to. This check guards that case by ensuring that we only iterate over an array of elements.
2021-12-02 15:55:42 +09:00
schneems 3f74eaa7a8 ~1.10x faster Change Ripper.lex structs to classes
## Concept

I am proposing we replace the Struct implementation of data structures inside of ripper with real classes.

This will improve performance and the implementation is not meaningfully more complicated.

## Example

Struct versus class comparison:

```ruby
Elem = Struct.new(:pos, :event, :tok, :state, :message) do
  def initialize(pos, event, tok, state, message = nil)
    super(pos, event, tok, State.new(state), message)
  end

  # ...

  def to_a
    a = super
    a.pop unless a.empty?
    a
  end
end

class ElemClass
  attr_accessor :pos, :event, :tok, :state, :message

  def initialize(pos, event, tok, state, message = nil)
    @pos = pos
    @event = event
    @tok = tok
    @state = State.new(state)
    @message = message
  end

  def to_a
    if @message
      [@pos, @event, @tok, @state, @message]
    else
      [@pos, @event, @tok, @state]
    end
  end
end

# stub state class creation for now
class State; def initialize(val); end; end
```

## MicroBenchmark creation

```ruby
require 'benchmark/ips'
require 'ripper'

pos = [1, 2]
event = :on_nl
tok = "\n".freeze
state = Ripper::EXPR_BEG

Benchmark.ips do |x|
  x.report("struct") { Elem.new(pos, event, tok, state) }
  x.report("class ") { ElemClass.new(pos, event, tok, state) }
  x.compare!
end; nil
```

Gives ~1.2x faster creation:

```
Warming up --------------------------------------
              struct   263.983k i/100ms
              class    303.367k i/100ms
Calculating -------------------------------------
              struct      2.638M (± 5.9%) i/s -     13.199M in   5.023460s
              class       3.171M (± 4.6%) i/s -     16.078M in   5.082369s

Comparison:
              class :  3170690.2 i/s
              struct:  2638493.5 i/s - 1.20x  (± 0.00) slower
```

## MicroBenchmark `to_a` (Called by Ripper.lex for every element)

```ruby
require 'benchmark/ips'
require 'ripper'

pos = [1, 2]
event = :on_nl
tok = "\n".freeze
state = Ripper::EXPR_BEG

struct =  Elem.new(pos, event, tok, state)
from_class = ElemClass.new(pos, event, tok, state)

Benchmark.ips do |x|
  x.report("struct") { struct.to_a }
  x.report("class ") { from_class.to_a }
  x.compare!
end; nil
```

Gives 1.46x faster `to_a`:

```
Warming up --------------------------------------
              struct   612.094k i/100ms
              class    893.233k i/100ms
Calculating -------------------------------------
              struct      6.121M (± 5.4%) i/s -     30.605M in   5.015851s
              class       8.931M (± 7.9%) i/s -     44.662M in   5.039733s

Comparison:
              class :  8930619.0 i/s
              struct:  6121358.9 i/s - 1.46x  (± 0.00) slower
```

## MicroBenchmark data access

```ruby
require 'benchmark/ips'
require 'ripper'

pos = [1, 2]
event = :on_nl
tok = "\n".freeze
state = Ripper::EXPR_BEG

struct =  Elem.new(pos, event, tok, state)
from_class = ElemClass.new(pos, event, tok, state)

Benchmark.ips do |x|
  x.report("struct") { struct.pos[1] }
  x.report("class ") { from_class.pos[1] }
  x.compare!
end; nil
```

Gives ~1.17x faster data access:

```
Warming up --------------------------------------
              struct     1.694M i/100ms
              class      1.868M i/100ms
Calculating -------------------------------------
              struct     16.149M (± 6.8%) i/s -     81.318M in   5.060633s
              class      18.886M (± 2.9%) i/s -     95.262M in   5.048359s

Comparison:
              class : 18885669.6 i/s
              struct: 16149255.8 i/s - 1.17x  (± 0.00) slower
```

## Full benchmark integration of this inside of Ripper.lex

Inside of this repo with this commit

```
$ cd ext/ripper
$ make
$ cat test.rb
file = File.join(__dir__, "../../array.rb")
source = File.read(file)

bench = Benchmark.measure do
  10_000.times.each do
    Ripper.lex(source)
  end
end

puts bench
```

Then execute with and without this change 50 times:

```
rm new.txt
rm old.txt
for i in {0..50}
do
  `ruby -Ilib -rripper -rbenchmark ./test.rb >> new.txt`
  `ruby -rripper -rbenchmark ./test.rb >> old.txt`
done
```

I used derailed benchmarks internals to compare the results:

```
dir = Pathname(".")
branch_info = {}
branch_info["old"]  = { desc: "Struct lex", time: Time.now, file: dir.join("old.txt"), name: "old" }
branch_info["new"]  = { desc: "Class lex", time: Time.now, file: dir.join("new.txt"), name: "new" }
stats = DerailedBenchmarks::StatsFromDir.new(branch_info)
stats.call.banner
```

Which gave us:

```
❤️ ❤️ ❤️  (Statistically Significant) ❤️ ❤️ ❤️

[new] (3.3139 seconds) "Class lex" ref: "new"
  FASTER 🚀🚀🚀 by:
    1.1046x [older/newer]
    9.4700% [(older - newer) / older * 100]
[old] (3.6606 seconds) "Struct lex" ref: "old"

Iterations per sample:
Samples: 51

Test type: Kolmogorov Smirnov
Confidence level: 99.0 %
Is significant? (max > critical): true
D critical: 0.30049534876137013
D max: 0.9607843137254902

Histograms (time ranges are in seconds):

   [new] description:                                        [old] description:
     "Class lex"                                               "Struct lex"
              ┌                                        ┐                ┌                                        ┐
   [3.0, 3.3) ┤▇ 1                                           [3.0, 3.3) ┤ 0
   [3.3, 3.6) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 47       [3.3, 3.6) ┤ 0
   [3.5, 3.8) ┤▇▇ 2                                          [3.5, 3.8) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 46
   [3.8, 4.1) ┤▇ 1                                           [3.8, 4.1) ┤▇▇▇ 4
   [4.0, 4.3) ┤ 0                                            [4.0, 4.3) ┤ 0
   [4.3, 4.6) ┤ 0                                            [4.3, 4.6) ┤▇ 1
              └                                        ┘                └                                        ┘
                         # of runs in range                                        # of runs in range
```

To sum this up, the "new" version of this code (using real classes instead of structs) is 10% faster across 50 runs with a statistical significance confidence level of 99%. Histograms are for visual checksum.
2021-12-02 15:55:42 +09:00
Nobuyoshi Nakada ae95939784
[ruby/win32ole] Fix typos [ci skip]
https://github.com/ruby/win32ole/commit/8d46bd0c93
2021-11-25 23:53:15 +09:00
Hiroshi SHIBATA 24f8f20cc7
[ruby/win32ole] LICENSE
https://github.com/ruby/win32ole/commit/62fd78078b
2021-11-25 23:53:14 +09:00
Nobuyoshi Nakada d896746d69
Keep the generated source files when clean [Bug #18363] 2021-11-25 19:16:39 +09:00
Peter Zhu c51b92c18d [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
2021-11-24 23:01:41 +09:00
Nobuyoshi Nakada da34f31ad0 [ruby/cgi] Fix integer overflow
Make use of the check in rb_alloc_tmp_buffer2.

https://hackerone.com/reports/1328463

https://github.com/ruby/cgi/commit/c728632c1c
2021-11-24 19:58:59 +09:00
Alan Wu f5d2041138
Avoid assert failure when NULL EC is expected
After 5680c38c75, postponed job APIs now
expect to be called on native threads not managed by Ruby and handles
getting a NULL execution context. However, in debug builds the change
runs into an assertion failure with GET_EC() which asserts that EC is
non-NULL. Avoid the assertion failure by passing `false` for `expect_ec`
instead as the intention is to handle when there is no EC.

Add a test from John Crepezzi and John Hawthorn to exercise this
situation.

See GH-4108
See GH-5094

[Bug #17573]

Co-authored-by: John Hawthorn <john@hawthorn.email>
Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2021-11-22 19:29:29 -05:00
Nobuyoshi Nakada ac152b3cac
Update dependencies 2021-11-21 16:21:18 +09:00
Hiroshi SHIBATA 39655aceb2 [ruby/date] Bump version to 3.2.2
https://github.com/ruby/date/commit/21d91c5f4f
2021-11-18 19:39:57 +09:00
Jean Boussier 3ce27552df [ruby/date] Expose Date::VERSION
An almost universal convention for gems is to expose `Namespace::VERSION`
which makes it mcuh easier when debugging etc.

Many gems extracted from ruby don't do this, even though it would be even more
useful because they ship with ruby, so it's less clear which version it is.

https://github.com/ruby/date/commit/fef7ec18d8
2021-11-18 19:39:55 +09:00
Yusuke Endoh d23b3d9b7d Prevent "already initialized constant Digest::VERSION"
http://rubyci.s3.amazonaws.com/ubuntu1804/ruby-master/log/20211117T033003Z.log.html.gz
```
installing default gems from ext:   /home/chkbuild/chkbuild/tmp/build/20211117T033003Z/lib/ruby/gems/3.1.0
/home/chkbuild/chkbuild/tmp/build/20211117T033003Z/ruby/ext/digest/lib/digest/version.rb:4: warning: already initialized constant Digest::VERSION
/home/chkbuild/chkbuild/tmp/build/20211117T033003Z/ruby/.ext/common/digest/version.rb:4: warning: previous definition of VERSION was here
```

This hack is copied from ext/psych/psych.gemspec
2021-11-17 15:08:46 +09:00
Yusuke Endoh cbb057e677 ext/io/wait/depend: make it work for Ruby 3.1.0-dev
Reverts 2eb3841e9c
because it fails on "update-deps" check in the ruby/ruby CI.

https://github.com/ruby/ruby/runs/4230891140?check_suite_focus=true
```
diff --git a/ext/io/wait/depend b/ext/io/wait/depend
index 7b314b9..449e9fe 100644
--- a/ext/io/wait/depend
+++ b/ext/io/wait/depend
...
```

Maybe now it does not work on Ruby 2.6. This file must be changed for
each Ruby version. I have no good idea to fix this issue.
2021-11-17 11:21:31 +09:00
Jean Boussier a87c56f820 [ruby/date] check_limit: also handle symbols
https://github.com/ruby/date/commit/376c65942b
2021-11-16 22:51:41 +09:00
Jean Boussier fa674cf723 [ruby/date] `Date._<format>(nil)` should return an empty Hash
Fix: https://github.com/ruby/date/issues/39

This is how versions previous to 3.2.1 behaved and Active Support
currently rely on this behavior.

90357af080/activesupport/lib/active_support/values/time_zone.rb (L383-L384)

Any Rails application upgrading to date `3.2.1` might run into unexpected errors.

https://github.com/ruby/date/commit/8f2d7a0c7e
2021-11-16 22:51:40 +09:00
Nobuyoshi Nakada 27168a1cf7 [ruby/nkf] Fix a typo [ci skip]
https://github.com/ruby/nkf/commit/18c118c83c
2021-11-16 21:07:19 +09:00
Yusuke Endoh 489c8cebf5 [ruby/date] Add length limit option for methods that parses date strings
`Date.parse` now raises an ArgumentError when a given date string is
longer than 128. You can configure the limit by giving `limit` keyword
arguments like `Date.parse(str, limit: 1000)`. If you pass `limit: nil`,
the limit is disabled.

Not only `Date.parse` but also the following methods are changed.

* Date._parse
* Date.parse
* DateTime.parse
* Date._iso8601
* Date.iso8601
* DateTime.iso8601
* Date._rfc3339
* Date.rfc3339
* DateTime.rfc3339
* Date._xmlschema
* Date.xmlschema
* DateTime.xmlschema
* Date._rfc2822
* Date.rfc2822
* DateTime.rfc2822
* Date._rfc822
* Date.rfc822
* DateTime.rfc822
* Date._jisx0301
* Date.jisx0301
* DateTime.jisx0301

https://github.com/ruby/date/commit/3959accef8
2021-11-16 20:56:56 +09:00
Nobuyoshi Nakada c910de3575 [ruby/io-wait] Fix dependency for ruby 2.6
https://github.com/ruby/io-wait/commit/2eb3841e9c
2021-11-16 20:25:47 +09:00
Nobuyoshi Nakada 96d9cfba08 [ruby/io-wait] Allow earlier versions
https://github.com/ruby/io-wait/commit/1060f9348c
2021-11-16 20:25:46 +09:00
Nobuyoshi Nakada db71a04c2e [ruby/io-wait] Fix backward compatibility with earlier versions
https://github.com/ruby/io-wait/commit/898248931f
2021-11-16 20:25:43 +09:00
Hiroshi SHIBATA 018266ca38
Merge digest-3.0.3.pre3 and efd76821b8 2021-11-16 19:42:20 +09:00
Akinori MUSHA 625cffc808 [ruby/digest] Abort loading if being loaded by gem/bundle pre Ruby 3.0.3
https://github.com/ruby/digest/commit/efd76821b8
2021-11-16 18:35:13 +09:00
xtkoba fed65e6a48 [ruby/digest] Avoid null pointer subtraction in digest/md5
Fixes warning on Clang 13.

Fixes [Bug #18076]

https://github.com/ruby/digest/commit/32135c7487
2021-11-16 18:35:07 +09:00
Peter Zhu aeae6e2842 [Feature #18290] Remove all usages of rb_gc_force_recycle
This commit removes usages of rb_gc_force_recycle since it is a burden
to maintain and makes changes to the GC difficult.
2021-11-08 14:05:54 -05:00
Nobuyoshi Nakada 2772f85648
Prefer ANSI-style prototypes over old K&R-style definitions 2021-11-08 17:08:01 +09:00
Nobuyoshi Nakada b47f7afbc3
Fix filename typo [Bug #18140] 2021-11-08 17:08:01 +09:00
Nobuyoshi Nakada 5b8d22ebe6 [ruby/openssl] Fix typos [ci skip]
https://github.com/ruby/openssl/commit/708ebf2f7a
2021-11-03 23:43:04 +09:00
Yusuke Endoh 8413749ec0 ext/socket/extconf.rb: Fix the chech if if_indextoname is available
The check had not work because "headers" were not passed.
2021-11-02 23:41:01 +09:00
Nobuyoshi Nakada a202408180
Fix typos 2021-11-02 19:17:37 +09:00
Kazuki Yamaguchi b474049c78 [ruby/openssl] x509name: improve docs for X509::Name
Add docs for X509::Name.parse_openssl and X509::Name.parse_rfc2253,
which are currently undocumented despite being widely used.

Small changes are also made to #to_s and the class description to
recommend using RFC 2253-based methods.

Fixes: https://github.com/ruby/openssl/issues/470

https://github.com/ruby/openssl/commit/74041a35d4
2021-11-01 17:48:03 +09:00
Kazuki Yamaguchi 1ac7f23bb8 [ruby/openssl] ssl: disallow reading/writing to unstarted SSL socket
OpenSSL::SSL::SSLSocket allowed #read and #write to be called before an
SSL/TLS handshake is completed. They passed unencrypted data to the
underlying socket.

This behavior is very odd to have in this library. A verbose mode
warning "SSL session is not started yet" was emitted whenever this
happened. It also didn't behave well with OpenSSL::Buffering. Let's
just get rid of it.

Fixes: https://github.com/ruby/openssl/issues/9

https://github.com/ruby/openssl/commit/bf780748b3
2021-11-01 17:48:02 +09:00
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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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().

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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)

https://github.com/ruby/openssl/commit/00abee791d
2021-10-25 00:40:42 +09:00
Hiroshi SHIBATA 1be2875e1d
[flori/json] Bump version to v2.6.1
https://github.com/flori/json/commit/2db5894cfa
2021-10-24 09:25:20 +09:00
Josef Šimánek 4cbce79438
[flori/json] Bump JSON::VERSION to 2.6.0.
https://github.com/flori/json/commit/da94d9f059
2021-10-24 09:25:01 +09:00
David Rodríguez d04d6bbc6c [ruby/psych] Prefer `require_relative` for internal requires
https://github.com/ruby/psych/commit/a0f55ee85a
2021-10-24 08:49:14 +09:00
Josef Šimánek 48cd633094 [ruby/psych] Add stringio as a dependency.
https://github.com/ruby/psych/commit/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.

https://github.com/ruby/strscan/commit/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.

https://github.com/ruby/openssl/commit/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
https://github.com/ruby/io-wait/commit/f6a1b10a59
2021-10-21 20:54:20 +09:00
Hiroshi SHIBATA 8eb8522f47 [ruby/stringio] Bump up stringio version to 3.0.1
https://github.com/ruby/stringio/commit/f7c40aa339
2021-10-21 20:53:53 +09:00
Hiroshi SHIBATA 5823168706 [ruby/psych] Bump up psych version to 4.0.2
https://github.com/ruby/psych/commit/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
https://github.com/ruby/etc/commit/85ca541d0b
2021-10-19 20:55:33 +09:00
Hiroshi SHIBATA b482a516d2 [ruby/zlib] Bump up zlib version to 2.1.1
https://github.com/ruby/zlib/commit/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

https://github.com/ruby/etc/commit/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.

https://github.com/ruby/openssl/commit/3436bd040d
2021-10-16 19:39:13 +09:00
Kazuki Yamaguchi 4991dabdd0 [ruby/openssl] bump version number to 3.0.0.pre
https://github.com/ruby/openssl/commit/baa83a8a57
2021-10-16 18:57:57 +09:00
Kazuki Yamaguchi cea3c55d58 [ruby/openssl] Ruby/OpenSSL 2.2.1
https://github.com/ruby/openssl/commit/65e7207a07
2021-10-16 18:34:35 +09:00
Kazuki Yamaguchi 75e72baba1 [ruby/openssl] Ruby/OpenSSL 2.1.3
https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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().

https://github.com/ruby/openssl/commit/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().

https://github.com/ruby/openssl/commit/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)

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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.

https://github.com/ruby/openssl/commit/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!!!

https://github.com/ruby/zlib/commit/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
https://github.com/ruby/date/commit/e0a4cbc8f6
2021-10-14 21:15:57 +09:00
Hiroshi SHIBATA b7f557178d [ruby/pathname] Bump up pathname version to 0.2.0
https://github.com/ruby/pathname/commit/e6b3b3ed25
2021-10-14 21:08:03 +09:00
Hiroshi SHIBATA f88628014a [ruby/nkf] Bump up nkf version to 0.1.1
https://github.com/ruby/nkf/commit/9aa7c6b841
2021-10-14 20:29:27 +09:00
Nobuyoshi Nakada d210950196
[ruby/etc] Get rid of alloca in the loop
https://github.com/ruby/etc/commit/c989bacc4c
2021-10-14 18:44:27 +09:00
Hiroshi SHIBATA 1220556f33
[ruby/fcntl] Bump up fcntl version to 1.0.1
https://github.com/ruby/fcntl/commit/0bcc0c4518
2021-10-14 17:18:21 +09:00
Hiroshi SHIBATA 91c2069dcf [flori/json] Bump up json version to 2.6.0
https://github.com/flori/json/commit/1942689b67
2021-10-14 17:04:37 +09:00
Hiroshi SHIBATA 6b13448040 [ruby/zlib] Bump up zlib version to 2.1.0
https://github.com/ruby/zlib/commit/dd593acaee
2021-10-14 16:18:41 +09:00
Hiroshi SHIBATA db500f05c2 [ruby/zlib] Bump version to v2.0.0
https://github.com/ruby/zlib/commit/434eba55ae
2021-10-14 16:18:36 +09:00
Hiroshi SHIBATA 9e86a60306
Removed redundant digest namespace 2021-10-14 14:07:50 +09:00
Hiroshi SHIBATA 3265af2f9e
separate pure ruby location under the digest/* extensions 2021-10-14 13:31:45 +09:00
Hiroshi SHIBATA 13772caee2
Move pure ruby files under the ext/gemname/lib directory. 2021-10-14 13:23:45 +09:00
Nobuyoshi Nakada 013bac15b0
Fix libraries under digest 2021-10-12 22:32:42 +09:00
Akinori MUSHA 01dc55ffad
[ruby/digest] Bump version to 3.1.0.pre2
https://github.com/ruby/digest/commit/5184207611
2021-10-12 20:53:18 +09:00
Akinori MUSHA ab787c493b
[ruby/digest] Bump version to 3.1.0.pre1
https://github.com/ruby/digest/commit/56679008cf
2021-10-12 20:53:18 +09:00
Pavel Rosický 10a0fac7e4
[ruby/digest] include jars
https://github.com/ruby/digest/commit/c15cbcd978
2021-10-12 20:53:17 +09:00
Akinori MUSHA e94bcda025
[ruby/digest] Bump version to 3.1.0.pre0
https://github.com/ruby/digest/commit/594cc4d548
2021-10-12 20:53:17 +09:00
Akinori MUSHA b245b67d9e
[ruby/digest] Place common parts in lib and engine specific parts under ext/**/lib
https://github.com/ruby/digest/commit/8d7496c3be
2021-10-12 20:53:16 +09:00
Pavel Rosický 5e1d2c5c97
[ruby/digest] relicence under the Ruby license and the BSD 2-clause
https://github.com/ruby/digest/commit/154d461e91
2021-10-12 20:46:16 +09:00
Pavel Rosický 94882df3a2
[ruby/digest] jruby support
https://github.com/ruby/digest/commit/2e9dc14693
2021-10-12 20:46:13 +09:00
Nobuyoshi Nakada ff1f696d30
[ruby/digest] Move digest.rb back under ext as the extension bundled library
https://github.com/ruby/digest/commit/026ba7f361
2021-10-12 20:44:14 +09:00
Kazuhiro NISHIYAMA 8dd6d58543 Add more socket constants
from http://manpages.ubuntu.com/manpages/focal/en/man2/socket.2.html
2021-10-12 16:45:22 +09:00
卜部昌平 5c167a9778 ruby tool/update-deps --fix 2021-10-05 14:18:23 +09:00
Rei Odaira ceeae31901 Avoid using the altzone variable in AIX
In AIX, altzone exists in the standard library but is not declared
in time.h.  By 524513be39, have_var
and try_var in mkmf recognizes a variable that exists in a library
even when it is not declared.  As a result, in AIX, HAVE_ALTZONE
is defined, but compile fails due to the lack of the declaration.
2021-10-02 21:23:34 -05:00
Jeremy Evans f9f7f3a75e [ruby/date] Make %v strftime flag use uppercase month
%v is supposed to be the VMS date, and VMS date format uses an
uppercase month.

Ruby 1.8 used an uppercase month for %v, but the behavior was
changed without explanation in r31672.

Time#strftime still uses an uppercase month for %v, so this change
makes Date#strftime consistent with Time#strftime.

Fixes [Bug #13810]

https://github.com/ruby/date/commit/56c489fd7e
2021-09-28 17:34:26 +09:00
Kazuhiro NISHIYAMA e0c6e8c64a
[DOC] Use `unpack1` instead of `unpack(template)[0]` [ci skip] 2021-09-23 09:20:00 +09:00
Nobuyoshi Nakada 289f3a79b5 [ruby/openssl] Add fallthrough comments
https://github.com/ruby/openssl/commit/258e30b640
2021-09-12 22:49:07 +09:00
Nobuyoshi Nakada 6920f3dc96 [ruby/openssl] Suppress cast-function-type warnings
https://github.com/ruby/openssl/commit/0f91e2a6ee
2021-09-12 22:49:05 +09:00
Nobuyoshi Nakada 598d66f6b2 [ruby/openssl] Separate formatting from ossl_make_error
Just append OpenSSL error reason to the given message string
object, which would be alreadly formatted.
Suppress -Wformat-security warning in `ossl_tsfac_create_ts`.

https://github.com/ruby/openssl/commit/11b1d8a6b8
2021-09-12 22:49:03 +09:00
Nobuyoshi Nakada c7dce12eb9 [ruby/openssl] Suppress printf format warnings
* Add `printf` format attribute to `ossl_raise`.
* Fix a format specifier in `config_load_bio`.
* Use `ASSUME` for the unreachable condition.

https://github.com/ruby/openssl/commit/41da2955db
2021-09-12 22:49:01 +09:00
Nobuyoshi Nakada 2bd6c5dc16 [ruby/date] Ignore warned variables
To suppress warnings at the compilation time.

https://github.com/ruby/date/commit/ff21132203
2021-09-09 13:56:13 +09:00
Hiroshi SHIBATA 8f752c95d2
[ruby/fiddle] Use test-unit gem (https://github.com/ruby/fiddle/pull/69)
https://github.com/ruby/fiddle/commit/e08c4c635e

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2021-09-05 17:43:48 +09:00
Nobuyoshi Nakada afa33da72b [ruby/fiddle] Create extconf header for MSVC
Not to include parenthesized argument.

https://github.com/ruby/fiddle/commit/c2c921e16a
2021-09-05 17:31:46 +09:00
Nobuyoshi Nakada ab63f6d854
Refined test [Bug #18140] 2021-09-02 09:11:41 +09:00
Aaron Patterson 8db269edb3
Guard array when appending
This prevents early collection of the array.  The GC doesn't see the
array on the stack when Ruby is compiled with optimizations enabled

Thanks @jhaberman for the test case

[ruby-core:105099] [Bug #18140]
2021-09-01 10:58:20 -07:00
Nobuyoshi Nakada d3155e3632 [ruby/zlib] Don't print out warnings when finalizing
https://github.com/ruby/zlib/commit/44a56d36e7
2021-08-31 23:20:42 +09:00
Nobuyoshi Nakada 31c427511c [ruby/zlib] Revert "Don't print out warnings when freeing."
https://github.com/ruby/zlib/commit/931aa7a272
2021-08-31 23:20:40 +09:00
jory-graham db154b20cc [ruby/psych] Replace A-Za-z with [:alpha:]
https://github.com/ruby/psych/commit/8ec36494fb
2021-08-31 19:34:54 +09:00
Aaron Patterson 9ed2cb26de [ruby/psych] Add quotes to the strings "y" and "n"
'y' and 'n' are kind of ambiguous.  Syck treated y and n literals in
YAML documents as strings.  But this is not what the YAML 1.1 spec says.
YAML 1.1 says they should be treated as booleans.  When we're dumping
documents, we know it's a string, so adding quotes will eliminate the
"ambiguity" in the emitted document

Fixes #443

https://github.com/ruby/psych/commit/6a1c30634e
2021-08-31 19:34:46 +09:00
opak 0925fddc80 [ruby/psych] Update lib/psych/scalar_scanner.rb
https://github.com/ruby/psych/commit/64cc239557

Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
2021-08-31 19:34:36 +09:00
Alexandr Opak 44353d0dee [ruby/psych] add more tests
https://github.com/ruby/psych/commit/8f71222bf3
2021-08-31 19:34:28 +09:00
Alexandr Opak 48b50cb4fe [ruby/psych] fix parsing integer values with '_' at the end
https://github.com/ruby/psych/commit/e0bb853014
2021-08-31 19:34:13 +09:00
Tomer Brisker 31ba0921f8 [ruby/psych] Improve float scalar scanner
Previously, `+.inf` was not handled correctly. Additionally, the regexp
was checking for inf and NaN, even though these cases are handled earlier
in the condition. Added a few tests to ensure handling some missing
cases.

https://github.com/ruby/psych/commit/6e0e7a1e9f
2021-08-31 19:34:06 +09:00
Samuel Williams d19af1675c [ruby/zlib] Don't print out warnings when freeing.
https://github.com/ruby/zlib/commit/098c50255d
2021-08-31 19:33:38 +09:00
Nobuyoshi Nakada 2dd26bed86
[Feature #16972] Add mode: option to Pathname#mkpath 2021-08-31 11:53:41 +09:00
schneems 51070ee5c4 Faster Pathname FileUtils methods
Currently when calling any of the "FileUtils" methods on pathname `require` is called every time even though that library might already be loaded. This is slow:

We can speed it up by either checking first if the constant is already defined, or by using autoload.

Using defined speeds up the action by about 300x and using autoload is about twice as fast as that (600x faster than current require method).

I'm proposing we use autoload:

```ruby
require 'benchmark/ips'

Benchmark.ips do |x|
  autoload(:FileUtils, "fileutils")
  x.report("require") { require 'fileutils' }
  x.report("defined") { require 'fileutils' unless defined?(FileUtils) }
  x.report("autoload") { FileUtils }

  x.compare!
end

# Warming up --------------------------------------
#              require     3.624k i/100ms
#              defined     1.465M i/100ms
#             autoload     2.320M i/100ms
# Calculating -------------------------------------
#              require     36.282k (± 2.4%) i/s -    184.824k in   5.097153s
#              defined     14.539M (± 2.0%) i/s -     73.260M in   5.041161s
#             autoload     23.100M (± 1.9%) i/s -    115.993M in   5.023271s

# Comparison:
#             autoload: 23099779.2 i/s
#              defined: 14538544.9 i/s - 1.59x  (± 0.00) slower
#              require:    36282.3 i/s - 636.67x  (± 0.00) slower
```

Because this autoload is scoped to Pathname it will not change the behavior of existing programs that are not expecting FileUtils to be loaded yet:

```
ruby -rpathname -e "class Pathname; autoload(:FileUtils, 'fileutils'); end; puts FileUtils.exist?"
Traceback (most recent call last):
-e:1:in `<main>': uninitialized constant FileUtils (NameError)
```
2021-08-30 15:18:11 +09:00
Peter Zhu c08d4067be [Feature #18045] Remove T_PAYLOAD
This commit removes T_PAYLOAD since the new VWA implementation no longer
requires T_PAYLOAD types.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-08-25 09:28:21 -04:00
Aaron Patterson 0f1e8f38c9 [ruby/fiddle] Improve "offsetof" calculations (https://github.com/ruby/fiddle/pull/90)
I need to get the offset of members inside sub structures.  This patch
adds sub-structure offset support for structs.

https://github.com/ruby/fiddle/commit/cf78eddbb6
2021-08-24 16:18:22 +09:00
Peter Zhu eddd369e73 Revert "[Feature #18045] Implement size classes for GC"
This reverts commits 48ff7a9f3e
and b2e2cf2ded because it is causing
crashes in SPARC solaris and i386 debian.
2021-08-23 10:54:53 -04:00
Peter Zhu 48ff7a9f3e [Feature #18045] Remove T_PAYLOAD
This commit removes T_PAYLOAD since the new VWA implementation no longer
requires T_PAYLOAD types.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-08-23 09:15:42 -04:00
Nobuyoshi Nakada 0b9a3371ea [ruby/date] Add zontab.list dependency
https://github.com/ruby/date/commit/7e1ffbf568
2021-08-22 20:28:52 +09:00
Mike Dalessio c0f4e4ca6d undefine alloc functions for C extensions
per guidance in doc/extension.rdoc, these classes now undefine their
alloc functions:

- ObjectSpace::InternalObjectWrapper
- Socket::Ifaddr
2021-08-20 08:30:06 +09:00
Nobuyoshi Nakada 36ae44ce2c
[ruby/date] Update zonetab.h at 2021-08-11
https://github.com/ruby/date/commit/de7dca353f
2021-08-17 22:57:59 +09:00
Nobuyoshi Nakada b8f7e8ac6b
Include ruby.h before internal headers to suppress -Wundef warnings 2021-08-09 19:25:18 +09:00
Nobuyoshi Nakada ae275f67ce Show WorkingSetSize as RSS on Windows 2021-08-05 17:14:38 +09:00
Nobuyoshi Nakada 3b52230452
Define functions using rb_wait_for_single_fd [Bug #18046] 2021-08-01 06:49:07 +09:00
Nobuyoshi Nakada 7564e066ff
Renamed thraed_fd_close as thread_fd 2021-07-29 21:15:04 +09:00
Hiroshi SHIBATA a889ab486e
Update the latest version of json.gemspec from flori/json 2021-07-29 15:57:58 +09:00
Rhys Powell e99d2d066f [ruby/psych] fix: use git repository link for LibYAML in docs
LibYAML has moved from their previous Mercurial based hosting on BitBucket to a git repository on GitHub. This commit updates the `Psych` module's documentation to point to this new repository, instead of the old one which is now a 404.

https://github.com/ruby/psych/commit/947a84d0dd
2021-07-29 15:54:41 +09:00
Jeremy Evans b3d62a77d9 [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
2021-07-28 13:40:03 +09:00
Hiroshi SHIBATA 30d0e5d1ae
[ruby/digest] Also drop to support Ruby 2.4
https://github.com/ruby/digest/commit/360a7de366
2021-07-28 11:48:36 +09:00
Hiroshi SHIBATA 260546ba26
[ruby/digest] Use Gemfile instead of Gem::Specification#add_development_dependency
https://github.com/ruby/digest/commit/460a6f807e
2021-07-28 11:48:36 +09:00
Hiroshi SHIBATA 5b96f4dd8c
[ruby/digest] Drop to support Ruby 2.3
https://github.com/ruby/digest/commit/23dc9c7425
2021-07-28 11:48:36 +09:00
Olle Jonsson 26e859b5c7
[ruby/digest] gemspec: Avoid distributing extraneous files
https://github.com/ruby/digest/commit/0a451e0c94
2021-07-28 11:48:36 +09:00
Olle Jonsson add48acea3
[ruby/digest] gemspec: Explicitly have 0 executables
https://github.com/ruby/digest/commit/086d54ba94
2021-07-28 11:48:36 +09:00
Olle Jonsson 478f0ddb5f
[ruby/digest] Experiment: Use a .pre version in gemspec
This makes it slightly more explicit that this is not a definite new version.

https://github.com/ruby/digest/commit/2bb5bb78a3
2021-07-28 11:48:36 +09:00
Olle Jonsson 73c5d4d54e
[ruby/digest] Experiment: bump patch version
This is a test, to see if the build failures are about the shipped Ruby master version of this gem.

https://github.com/ruby/digest/commit/d2606b2cce
2021-07-28 11:48:36 +09:00
Nobuyoshi Nakada 070557afc4 Distinguish signal and timeout [Bug #16608] 2021-07-25 13:09:03 -07:00
Benoit Daloze 9b972310fa [ruby/racc] Add missing check for rb_block_call()
* It used to be hardcoded since 0affbf9d2c7c5c618b8d3fe191e74d9ae8ad22fc
  but got removed in 23abf3d3fb82afcc26d35769f0dec59dd46de4bb
* This means that since that second commit, rb_iterate() was used unintentionally.

https://github.com/ruby/racc/commit/8816ced525
2021-07-18 20:38:34 +09:00
Kazuki Yamaguchi bd356c6899 [ruby/openssl] Strip trailing spaces
https://github.com/ruby/openssl/commit/68fa9c86f1
2021-07-18 18:04:50 +09:00
Samuel Williams 3f1d8a18ea [ruby/openssl] Deprecate and rework old (fd) centric functions
[ky: fixed compatibility with older versions of Ruby]

(cherry picked from commit ruby/ruby@45e65f302b)

https://github.com/ruby/openssl/commit/8d928e0fb9
2021-07-18 17:48:49 +09:00
Benoit Daloze 3975840780 [ruby/openssl] Use rb_block_call() instead of the deprecated rb_iterate() in OpenSSL
* See https://bugs.ruby-lang.org/issues/18025
  and https://github.com/ruby/ruby/pull/4629

https://github.com/ruby/openssl/commit/b8e4852dcc
2021-07-18 17:48:49 +09:00
Yusuke Nakamura 11651ab703 [ruby/openssl] Add example to OpenSSL::KDF.hkdf method (https://github.com/ruby/openssl/pull/447)
The values from RFC 5869
https://datatracker.ietf.org/doc/html/rfc5869#appendix-A.1

https://github.com/ruby/openssl/commit/ec14a87f4f
2021-07-18 17:48:49 +09:00
Kazuki Yamaguchi 70f0a802fe [ruby/openssl] use Bundler for dependency management and Rake gem tasks
Back in 2016, we chose not to use Bundler in Ruby/OpenSSL development
because Bundler depended on openssl and could not be used for testing
openssl itself - "bundle exec rake test" would end up with loading two
different versions of openssl at the same time.

This has been resolved long time ago. We can now safely use it for
development dependency management and for Rake tasks.

https://github.com/ruby/openssl/commit/47283d9161
2021-07-18 17:48:42 +09:00
Vinicius Stock 4f7c3f631a [ruby/openssl] Include peer socket IP address in errors
https://github.com/ruby/openssl/commit/8a1e3f5085
2021-07-18 17:45:03 +09:00
Yusuke Endoh 3d37e5d11c [ruby/openssl] Add OpenSSL::BN#set_flags and #get_flags
Also, OpenSSL::BN::CONSTTIME is added.

OpenSSL itself had a feature that was vulnerable against a side-channel
attack. The OpenSSL authors determined that it was not a security issue,
and they have already fixed the issue by using BN_set_flags.

https://github.com/openssl/openssl/pull/13888

If a Ruby OpenSSL user was faced with a similar issue, they couldn't
prevent the issue because Ruby OpenSSL lacks a wrapper to BN_set_flags.
For the case, this change introduces the wrapper.

https://github.com/ruby/openssl/commit/1e565eba89
2021-07-18 17:45:02 +09:00
Kazuki Yamaguchi 5fc2912e60 [ruby/openssl] pkey/dsa: refactor DSA#sys{sign,verify} with PKey#{sign,verify}_raw
With the newly added OpenSSL::PKey::PKey#{sign,verify}_raw,
OpenSSL::PKey::DSA's low level signing operation methods can be
implemented in Ruby. The definitions are now in lib/openssl/pkey.rb.

https://github.com/ruby/openssl/commit/ce805adf0c
2021-07-18 17:45:01 +09:00
Kazuki Yamaguchi 0c23e4a7aa [ruby/openssl] pkey/ec: refactor EC#dsa_{sign,verify}_asn1 with PKey#{sign,verify}_raw
With the newly added OpenSSL::PKey::PKey#{sign,verify}_raw,
OpenSSL::PKey::EC's low level signing operation methods can be
implemented in Ruby. The definitions are now in lib/openssl/pkey.rb.

https://github.com/ruby/openssl/commit/1f9da0cd9d
2021-07-18 17:45:00 +09:00
Kazuki Yamaguchi 857a177b03 [ruby/openssl] pkey/rsa: port RSA#{private,public}_{encrypt,decrypt} to the EVP API
Implement these methods using the new OpenSSL::PKey::PKey#{encrypt,sign}
family. The definitions are now in lib/openssl/pkey.rb.

Also, recommend using those generic methods in the documentation.

https://github.com/ruby/openssl/commit/2dfc1779d3
2021-07-18 17:44:59 +09:00
Kazuki Yamaguchi 4ebff35971 [ruby/openssl] pkey: implement PKey#sign_raw, #verify_raw, and #verify_recover
Add a variant of PKey#sign and #verify that do not hash the data
automatically.

Sometimes the caller has the hashed data only, but not the plaintext
to be signed. In that case, users would have to use the low-level API
such as RSA#private_encrypt or #public_decrypt directly.

OpenSSL 1.0.0 and later supports EVP_PKEY_sign() and EVP_PKEY_verify()
which provide the same functionality as part of the EVP API. This patch
adds wrappers for them.

https://github.com/ruby/openssl/commit/16cca4e0c4
2021-07-18 17:44:58 +09:00
Kazuki Yamaguchi cbc560e38f [ruby/openssl] pkey: update version reference in #sign and #verify documentation
The next release is decided to be 3.0 rather than 2.3.

https://github.com/ruby/openssl/commit/b8a434e462
2021-07-18 17:44:58 +09:00
Kazuki Yamaguchi 87458ff2ae [ruby/openssl] pkey: implement PKey#encrypt and #decrypt
Support public key encryption and decryption operations using the EVP
API.

https://github.com/ruby/openssl/commit/75326d4bbc
2021-07-18 17:44:57 +09:00
Kazuki Yamaguchi eac7fd57f8 [ruby/openssl] pkey: remove deprecated parameter setters
Remove the following methods, which have been marked as deprecated and
produced a warning since version 2.0, commit 7ea72f1f5084 ("adapt
OpenSSL::PKey to OpenSSL 1.1.0 opaque structs", 2016-06-05).

 - OpenSSL::PKey::RSA#n=, #e=, #d=, #p=, #q=, #dmp1=, #dmq1=, #iqmp=
 - OpenSSL::PKey::DSA#p=, #q=, #g=, #priv_key=, #pub_key=
 - OpenSSL::PKey::DH#p=, #g=, #priv_key=, #pub_key=

These methods could only work with OpenSSL 1.0.2 or older, which is now
EOL.

https://github.com/ruby/openssl/commit/2334862cc0
2021-07-18 17:44:56 +09:00
Samuel Williams 1146a94aee [ruby/openssl] Implement `Certificate.load` to load certificate chain. (https://github.com/ruby/openssl/pull/441)
* Add feature for loading the chained certificate into Certificate array.

https://github.com/ruby/openssl/commit/05e1c015d6

Co-authored-by: Sao I Kuan <saoikuan@gmail.com>
2021-07-18 17:44:55 +09:00
Kazuki Yamaguchi a01daab656 [ruby/openssl] x509, ssl, pkcs7: try to parse as DER-encoding first
Methods that take both PEM-encoding and DER-encoding have not been
consistent in the order in which encoding to attempt to parse.

A DER-encoding may contain a valid PEM block ("\n-----BEGIN ..-----" to
"-----END ...-----") embedded within it. Also, the PEM-encoding parser
allows arbitrary data around the PEM block and silently skips it. As a
result, attempting to parse data in DER-encoding as PEM-encoding first
can incorrectly finds the embedded PEM block instead.

This commit ensures that DER encoding will always be attempted before
PEM encoding. OpenSSL::X509::Certificate is one of the updated classes.
With this, the following will always be true:

    # obj is an OpenSSL::X509::Certificate
    obj == OpenSSL::X509::Certificate.new(obj.to_der)
    obj == OpenSSL::X509::Certificate.new(obj.to_pem)

https://github.com/ruby/openssl/commit/b280eb1fd0
2021-07-18 17:44:54 +09:00
Ryuta Kamizono 29ad4ab3d0 [ruby/openssl] Fix some typos [ci skip]
https://github.com/ruby/openssl/commit/51b3030b2b
2021-07-18 17:44:54 +09:00
Aaron Patterson 593164c2be [ruby/openssl] Add SSLSocket#getbyte
Normal sockets respond to `getbyte`, so we should make SSLSocket respond
to `getbyte` as well.  This way we can substitute SSLSockets for regular
sockets.

https://github.com/ruby/openssl/commit/ac1490b7c9
2021-07-18 17:44:53 +09:00
Kazuki Yamaguchi 6d71918d94 [ruby/openssl] pkey/dh, pkey/ec: use EVP_PKEY_check() family
Use EVP_PKEY_param_check() instead of DH_check() if available. Also,
use EVP_PKEY_public_check() instead of EC_KEY_check_key().

EVP_PKEY_*check() is part of the EVP API and is meant to replace those
low-level functions. They were added by OpenSSL 1.1.1. It is currently
not provided by LibreSSL.

https://github.com/ruby/openssl/commit/797e9f8e08
2021-07-18 17:44:52 +09:00
Kazuki Yamaguchi 3fe8387950 [ruby/openssl] pkey: implement {DH,DSA,RSA}#public_key in Ruby
The low-level API that is used to implement #public_key is deprecated
in OpenSSL 3.0. It is actually very simple to implement in another way,
using existing methods only, in much shorter code. Let's do it.

While we are at it, the documentation is updated to recommend against
using #public_key. Now that OpenSSL::PKey::PKey implements public_to_der
method, there is no real use case for #public_key in newly written Ruby
programs.

https://github.com/ruby/openssl/commit/48a6c391ef
2021-07-18 17:44:51 +09:00
Kazuki Yamaguchi 5d1693aac5 [ruby/openssl] pkey: implement #to_text using EVP API
Use EVP_PKEY_print_private() instead of the low-level API *_print()
functions, such as RSA_print().

EVP_PKEY_print_*() family was added in OpenSSL 1.0.0.

Note that it falls back to EVP_PKEY_print_public() and
EVP_PKEY_print_params() as necessary. This is required for EVP_PKEY_DH
type for which _private() fails if the private component is not set in
the pkey object.

Since the new API works in the same way for all key types, we now
implement #to_text in the base class OpenSSL::PKey::PKey rather than in
each subclass.

https://github.com/ruby/openssl/commit/e0b4c56956
2021-07-18 17:44:50 +09:00
Kazuki Yamaguchi 436aecb520 [ruby/openssl] pkey: remove unused ossl_generate_cb_2() helper function
The previous series of commits re-implemented key generation with the
low level API with the EVP API. The BN_GENCB-based callback function is
no longer used.

https://github.com/ruby/openssl/commit/81027b7463
2021-07-18 17:44:50 +09:00
Kazuki Yamaguchi 38436d1f5c [ruby/openssl] pkey/dsa: use high level EVP interface to generate parameters and keys
Implement PKey::DSA.new(size) and PKey::DSA.generate using
OpenSSL::PKey.generate_parameters and .generate_key instead of the low
level DSA functions.

https://github.com/ruby/openssl/commit/1800a8d5eb
2021-07-18 17:44:49 +09:00
Kazuki Yamaguchi b8dcf9c8fd [ruby/openssl] pkey/rsa: use high level EVP interface to generate parameters and keys
Implement PKey::RSA.new(size, exponent) and PKey::RSA.generate using
OpenSSL::PKey.generate_key instead of the low level RSA functions.

https://github.com/ruby/openssl/commit/363fd10713
2021-07-18 17:44:48 +09:00
Kazuki Yamaguchi 098985a5e6 [ruby/openssl] pkey/dh: use high level EVP interface to generate parameters and keys
Implement PKey::DH.new(size, gen), PKey::DH.generate(size, gen), and
PKey::DH#generate_key! using PKey.generate_parameters and .generate_key
instead of the low level DH functions.

Note that the EVP interface can enforce additional restrictions - for
example, DH key shorter than 2048 bits is no longer accepted by default
in OpenSSL 3.0. The test code is updated accordingly.

https://github.com/ruby/openssl/commit/c2e9b16f0b
2021-07-18 17:44:47 +09:00
Kazuki Yamaguchi 595644e4f6 [ruby/openssl] pkey: fix interrupt handling in OpenSSL::PKey.generate_key
rb_thread_call_without_gvl() can be interrupted, but it may be able to
resume the operation. Call rb_thread_check_ints() to see if it raises
an exception or not.

https://github.com/ruby/openssl/commit/88b90fb856
2021-07-18 17:44:46 +09:00
Kazuki Yamaguchi 8cfe92b8a2 [ruby/openssl] pkey: allow setting algorithm-specific options in #sign and #verify
Similarly to OpenSSL::PKey.generate_key and .generate_parameters, let
OpenSSL::PKey::PKey#sign and #verify take an optional parameter for
specifying control strings for EVP_PKEY_CTX_ctrl_str().

https://github.com/ruby/openssl/commit/faf85d7c1d
2021-07-18 17:44:46 +09:00
Kazuki Yamaguchi e2014d0354 [ruby/openssl] pkey: prepare pkey_ctx_apply_options() for usage by other operations
The routine to apply Hash to EVP_PKEY_CTX_ctrl_str() is currently used
by key generation, but it is useful for other operations too. Let's
change it to a slightly more generic name.

https://github.com/ruby/openssl/commit/b2b77527fd
2021-07-18 17:44:45 +09:00
Kazuki Yamaguchi 1706302be5 [ruby/openssl] pkey: fix potential memory leak in PKey#sign
Fix potential leak of EVP_MD_CTX object in an error path. This path is
normally unreachable, since the size of a signature generated by any
supported algorithms would not be larger than LONG_MAX.

https://github.com/ruby/openssl/commit/99e8630518
2021-07-18 17:44:44 +09:00
Kazuki Yamaguchi b7a908af34 [ruby/openssl] ossl.c: do not set locking callbacks on LibreSSL
Similarly to OpenSSL >= 1.1.0, LibreSSL 2.9.0 ensures thread safety
without requiring applications to set locking callbacks and made
related functions no-op.

https://github.com/ruby/openssl/commit/7276233e1a
2021-07-18 17:44:43 +09:00
Kazuki Yamaguchi 88d64418dd [ruby/openssl] ssl: use TLS_method() instead of SSLv23_method() for LibreSSL
LibreSSL 2.2.2 introduced TLS_method(), but with different semantics
from OpenSSL: TLS_method() enabled TLS >= 1.0 while SSLv23_method()
enabled all available versions, which included SSL 3.0 in addition.

However, LibreSSL 2.3.0 removed SSL 3.0 support completely and now
TLS_method() and SSLv23_method() are equivalent.

https://github.com/ruby/openssl/commit/3b7d7045b8
2021-07-18 17:44:43 +09:00
Kazuki Yamaguchi 50332c4071 [ruby/openssl] ssl: call SSL_CTX_set_ecdh_auto() on OpenSSL 1.0.2 only
SSL_CTX_set_ecdh_auto() exists in OpenSSL 1.1.0 and LibreSSL 2.6.1, but
it is made no-op and the automatic curve selection cannot be disabled.
Wrap it with ifdef to make it clear that it is safe to remove it
completely when we drop support for OpenSSL 1.0.2.

https://github.com/ruby/openssl/commit/2ae8f21234
2021-07-18 17:44:42 +09:00
Kazuki Yamaguchi cd002305f0 [ruby/openssl] require OpenSSL >= 1.0.2 and LibreSSL >= 3.1
Clean up old version guards in preparation for the upcoming OpenSSL 3.0
support.

OpenSSL 1.0.1 reached its EOL on 2016-12-31. At that time, we decided
to keep 1.0.1 support because many major Linux distributions were still
shipped with 1.0.1. Now, nearly 4 years later, most Linux distributions
are reaching their EOL and it should be safe to assume nobody uses them
anymore. Major ones that were using 1.0.1:

 - Ubuntu 14.04 is EOL since 2019-04-30
 - RHEL 6 will reach EOL on 2020-11-30

LibreSSL 3.0 and older versions are no longer supported by the LibreSSL
team as of October 2020.

Note that OpenSSL 1.0.2 also reached EOL on 2019-12-31 and 1.1.0 also
did on 2018-08-31.

https://github.com/ruby/openssl/commit/c055938f4b
2021-07-18 17:44:41 +09:00
Kazuki Yamaguchi decce40da7 [ruby/openssl] bn: update documentation of OpenSSL::BN#initialize and #to_s
Clarify that BN.new(str, 2) and bn.to_s(2) handles binary string in
big-endian, and the sign of the bignum is ignored.

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

https://github.com/ruby/openssl/commit/6fae2bd612
2021-07-18 17:44:40 +09:00
Rick Mark 01fcb8f45b [ruby/openssl] BN.abs and BN uplus
Adds standard math abs fuction and revises uplus to return a duplicated object due to BN mutability

https://github.com/ruby/openssl/commit/0321b1e945
2021-07-18 17:44:39 +09:00
Kenta Murata 67897762cf
[ruby/fiddle] Add Fiddle::Handle#file_name (https://github.com/ruby/fiddle/pull/88)
https://github.com/ruby/fiddle/commit/4ee1c6fc4b
2021-07-14 18:56:00 +09:00
Nobuyoshi Nakada 169529a0c0
[ruby/fiddle] Check HAVE_RUBY_MEMORY_VIEW_H rather than API version (https://github.com/ruby/fiddle/pull/86)
https://github.com/ruby/fiddle/commit/c5abcc3a7e
2021-07-14 18:55:59 +09:00
Kenta Murata 818c74b7f4 [ruby/fiddle] Return the module handle value in Fiddle::Handle#to_i and add FIddle::Handle#to_ptr (https://github.com/ruby/fiddle/pull/87)
https://github.com/ruby/fiddle/commit/170111a0cb
2021-07-14 18:43:32 +09:00
Nobuyoshi Nakada cb955dc9ac
[ruby/fiddle] update dependencies 2021-07-13 21:34:28 +09:00
Nobuyoshi Nakada 40d45ab093
[ruby/fiddle] Check HAVE_RUBY_MEMORY_VIEW_H rather than API version
https://github.com/ruby/fiddle/commit/93f9564446
2021-07-13 20:36:45 +09:00
Nobuyoshi Nakada 472d8c5555
[ruby/fiddle] Update required_ruby_version (https://github.com/ruby/fiddle/pull/85)
Drop supports for old versions, keeping 2.5 as CI supports it for
now.

https://github.com/ruby/fiddle/commit/90634e7c55
2021-07-13 19:37:46 +09:00
Sutou Kouhei bb868f4814
[ruby/fiddle] Use have_header and have_type to detect memory view availability
Fix https://github.com/ruby/fiddle/pull/84

It may detect ruby/memory_view.h for system Ruby that is installed in
/usr.

We can use RUBY_API_VERSION_MAJOR to detect memory view availability
because memory view is available since Ruby 3.0.

Reported by Jun Aruga. Thanks!!!

https://github.com/ruby/fiddle/commit/3292929830
2021-07-13 19:37:46 +09:00
Aaron Patterson 5c0d8c6369
[ruby/fiddle] Add "offsetof" to Struct classes (https://github.com/ruby/fiddle/pull/83)
* Add "offsetof" to Struct classes

I need to get the offset of a member inside a struct without allocating
the struct.  This patch adds an "offsetof" class method to structs that
are generated.

The usage is like this:

```ruby
MyStruct = struct [
  "int64_t i",
  "char c",
]

MyStruct.offsetof("i") # => 0
MyStruct.offsetof("c") # => 8
```

* Update test/fiddle/test_c_struct_builder.rb

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>

https://github.com/ruby/fiddle/commit/4e3b60c5b6

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
2021-07-13 19:37:46 +09:00
Sutou Kouhei a2c9e1b58a
[ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/049138b4b8
2021-07-13 19:37:46 +09:00
Sutou Kouhei 70b0318646
[ruby/fiddle] MemoryView: ensure reset rb_memory_view_t::obj on error
https://github.com/ruby/fiddle/commit/0ed39345fe
2021-07-13 19:37:46 +09:00
Sutou Kouhei 9f86e50e1e
[ruby/fiddle] StringValuePtr may change the val
https://github.com/ruby/fiddle/commit/bddca7c895
2021-07-13 19:37:45 +09:00
Sutou Kouhei 10e26cfa76
[ruby/fiddle] Add MemoryView.export and MemoryView#release (https://github.com/ruby/fiddle/pull/80)
fix https://github.com/ruby/fiddle/pull/79

Users can release memory views explicitly before process exit.

Reported by xtkoba. Thanks!!!

https://github.com/ruby/fiddle/commit/1de64b7e76
2021-07-13 19:37:45 +09:00
Sutou Kouhei 9988f6ac4e
[ruby/fiddle] Add Fiddle::MemoryView#to_s (https://github.com/ruby/fiddle/pull/78)
Fix https://github.com/ruby/fiddle/pull/74

Reported by dsisnero. Thanks!!!
2021-07-13 19:37:45 +09:00
Sutou Kouhei d1eeb9fec9
[ruby/fiddle] windows: use GetLastError() for win32_last_error
Ruby: [Bug #11579]

Patch by cremno phobia. Thanks!!!

https://github.com/ruby/fiddle/commit/760a8f9b14
2021-07-13 19:37:45 +09:00
Sutou Kouhei c0f9191ab6
[ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/3784cfeec4
2021-07-13 19:37:44 +09:00
Samuel Williams 028441d22f Avoid calling `fstat` on things we already know are valid sockets. 2021-07-12 19:16:22 +12:00
Nobuyoshi Nakada c2ed5ab08b [ruby/date] Fixed markups for bold [ci skip]
https://github.com/ruby/date/commit/404f9d2096
2021-07-11 20:28:23 +09:00
Jeremy Evans 8065670cfb [ruby/date] Fix comparison with Float::INFINITY
Fixes [Bug #17945]

https://github.com/ruby/date/commit/953d907238
2021-07-11 20:28:21 +09:00
Nobuyoshi Nakada fbe9b691bd
Added missing declarations in readline.h bundled with macOS 10.13 2021-07-09 08:52:35 +09:00
Nobuyoshi Nakada 771f6dd75d
[ruby/stringio] Suppress a sign-compare warning
https://github.com/ruby/stringio/commit/a88c070e0b
2021-07-08 16:43:22 +09:00
Nobuyoshi Nakada eecc4570cd
Found library is not usable if the header is not found 2021-07-06 01:17:38 +09:00
Nobuyoshi Nakada 1dfe75b0be
Fixed 'maybe_unused' attribute
```
../../../src/ext/bigdecimal/bigdecimal.c:303:5: error: 'maybe_unused' attribute cannot be applied to types
    ENTER(1);
    ^
```
2021-07-06 01:13:54 +09:00
Nobuyoshi Nakada 6d8422659a
Fix linking bundled zlib
* Prefix "./" to the import library name to expanded when static
  linking exts.

* Copy zlib shared library to the top build directory.
2021-07-03 12:52:46 +09:00
Samuel Williams 5e75280c8e Add basic test for updated IO wait functions. 2021-06-29 23:54:41 +12:00
Nobuyoshi Nakada 391abc543c
Scan the coderange in the given encoding 2021-06-26 16:05:15 +09:00
Nobuyoshi Nakada fd7023a87e
Convert ssize_t properly 2021-06-23 10:09:25 +09:00
Samuel Williams 45e65f302b Deprecate and rework old (fd) centric functions. 2021-06-22 22:48:57 +12:00
Samuel Williams 3deb5d7113 Direct io for accept, send, sendmsg, recvfrom, and related methods. 2021-06-22 22:17:53 +12:00