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

8601 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada ef1c1ddf68
Use `rb_sprintf` instead of deprecated `sprintf` 2022-11-09 11:58:37 +09:00
yui-knk f7db1affd1 Set default %printer for NODE nterms
Before:

```
Reducing stack by rule 639 (line 5062):
   $1 = token "integer literal" (1.0-1.1: 1)
-> $$ = nterm simple_numeric (1.0-1.1: )
```

After:

```
Reducing stack by rule 641 (line 5078):
   $1 = token "integer literal" (1.0-1.1: 1)
-> $$ = nterm simple_numeric (1.0-1.1: NODE_LIT)
```

`"<*>"` is supported by Bison 2.3b (2008-05-27) or later.
https://git.savannah.gnu.org/cgit/bison.git/commit/?id=12e3584054c16ab255672c07af0ffc7bb220e8bc

Therefore developers need to install Bison 2.3b+ to build ruby from
source codes if their Bison is older.

Minimum version requirement for Bison is changed to 3.0.

See: https://bugs.ruby-lang.org/issues/19068 [Feature #19068]
2022-11-08 12:30:03 +09:00
Takashi Kokubun 9af344a421 [ruby/erb] Revert the strpbrk optimization
because it's much slower on M1 https://github.com/ruby/erb/pull/29.
It'd be too complicated to switch the implementation based on known
optimized platforms / versions.

Besides, short strings are the most common usages of this method and
SIMD doesn't really help that case. All in all, I can't justify the
existence of this code.

https://github.com/ruby/erb/commit/30691c8995
2022-11-05 08:34:32 +00:00
Takashi Kokubun 458d6fb15e [ruby/erb] Optimize away the rb_convert_type call using RB_TYPE_P
https://github.com/ruby/erb/commit/12058c3784
2022-11-05 07:52:46 +00:00
Takashi Kokubun e8873e01b6 [ruby/erb] Use strpbrk only when str is long enough for SIMD
This is the same trick used by https://github.com/k0kubun/hescape to
choose the best strategy for different scenarios.

https://github.com/ruby/erb/commit/af26da2858
2022-11-05 07:52:45 +00:00
Takashi Kokubun 419d2fc14d [ruby/erb] Optimize the no-escape case with strpbrk
(https://github.com/ruby/erb/pull/29)

Typically, strpbrk(3) is optimized pretty well with SIMD instructions.
Just using it makes this as fast as a SIMD-based implementation for the
no-escape case.

Not utilizing this for escaped cases because memory allocation would be
a more significant bottleneck for many strings anyway. Also, there'll be
some overhead in calling a C function (strpbrk) many times because we're
not using SIMD instructions directly. So using strpbrk all the time
might not necessarily be faster.
2022-11-05 06:58:48 +00:00
Takashi Kokubun b169d78c88 [ruby/erb] Avoid using prepend + super for fallback
(https://github.com/ruby/erb/pull/28)

`prepend` is prioritized more than ActiveSupport's monkey-patch, but the
monkey-patch needs to work.

https://github.com/ruby/erb/commit/611de5a865
2022-11-04 16:46:29 +00:00
Nobuyoshi Nakada 13395757fa
Update dependencies for bc28acc347 2022-11-05 00:48:42 +09:00
Nobuyoshi Nakada cb18deee72
Substitute from the actual netinet6/in6.h
Xcode no longer links the system include files directory to `/usr`.
Extract the actual header file path from cpp output.
2022-11-04 17:38:28 +09:00
Takashi Kokubun ccf32a5ca4 [ruby/erb] Do not allocate a new String if not needed
[Feature #19102]https://github.com/ruby/erb/commit/ecebf8075c
2022-11-04 07:07:24 +00:00
Takashi Kokubun 20efeaddbe [ruby/erb] Optimize away to_s if it's already T_STRING
[Feature #19102]https://github.com/ruby/erb/commit/38c6e182fb
2022-11-04 07:07:24 +00:00
Takashi Kokubun dc5d06e9b1 [ruby/erb] Copy CGI.escapeHTML to ERB::Util.html_escape
https://github.com/ruby/erb/commit/ac9b219fa9
2022-11-04 07:07:23 +00:00
Peter Zhu 4a8cd9e8bc Use shared flags of the type
The ELTS_SHARED flag is generic, so we should prefer to use the flags
specific of the type (STR_SHARED for strings and RARRAY_SHARED_FLAG
for arrays).
2022-11-02 11:03:21 -04:00
Nobuyoshi Nakada 7ed10abdd9 [ruby/bigdecimal] Suppress macro redefinition warnings
`HAVE_` macros by autoconf are defined as 1.

https://github.com/ruby/bigdecimal/commit/cd35868aa6
2022-10-30 14:21:31 +00:00
Nobuyoshi Nakada bc28acc347 [ruby/digest] Use CommonDigest by default if available
https://github.com/ruby/digest/commit/cce9ada85e
2022-10-29 12:06:03 +00:00
Nobuyoshi Nakada 739ad81ff1 [ruby/date] Check month range as civil 2022-10-27 05:36:11 +00:00
Nobuyoshi Nakada 711b2ed5fe
Make the timestamp path correspond to the bundled target path
So different timestamps for different paths will be used.  Extentions
paths in bundled gems contain `ruby_version`, which includes the ABI
version, and the same timestamp file for different paths resulted in
build failures when it changed.
2022-10-24 17:47:59 +09:00
Burdette Lamar 35e03a44b8 [ruby/stringio] [DOC] Enhanced RDoc for StringIO
(https://github.com/ruby/stringio/pull/36)

Treats:
- #each_codepoint
- #gets
- #readline (shows up in doc for module IO::generic_readable, not class
StringIO)
- #each_line

https://github.com/ruby/stringio/commit/659aca7fe5
2022-10-21 14:12:45 +00:00
Jemma Issroff 6aed5b0c11 Unmark Internal IV test as pending
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2022-10-20 11:59:34 -07:00
Burdette Lamar c32180d5ce [ruby/stringio] [DOC] Enhanced RDoc for StringIO
(https://github.com/ruby/stringio/pull/35)

Treated:
- #getc
- #getbyte
- #ungetc
- #ungetbyte
- #readchar
- #readbyte
- #each_char

https://github.com/ruby/stringio/commit/6400af8d9f
2022-10-19 15:33:08 +00:00
Burdette Lamar 18b96d8a82 [ruby/stringio] [DOC] StringIO doc enhancements
(https://github.com/ruby/stringio/pull/33)

Treated:
- ::new
- ::open
- #string
- #string=
- #close
- #close_read
- #close_write
- #closed?
- #closed_read?
- #closed_write?
- #eof?

https://github.com/ruby/stringio/commit/be9b64d739
2022-10-19 09:12:18 +09:00
Nobuyoshi Nakada 01d56b99bf
[DOC] Fix rdoc-ref 2022-10-19 08:52:29 +09:00
Burdette Lamar 6bd72a6406 [DOC] Enhanced RDoc for StringIO (#34)
Treated:
- #lineno
- #lineno=
- #binmode
- #reopen
- #pos
- #pos=
- #rewind
- #seek
- #sync
- #each_byte
2022-10-18 18:41:00 +00:00
Aaron Patterson dffca50bb6 [ruby/fiddle] Free closures immediately
(https://github.com/ruby/fiddle/pull/109)

These structs don't need to be freed as part of finalization, so lets
free them immediately.

https://github.com/ruby/fiddle/commit/8a10ec1152
2022-10-18 17:21:45 +09:00
Sutou Kouhei e84ea4af69 [ruby/fiddle] Add support for linker script on Linux
GitHub: fix https://github.com/ruby/fiddle/pull/107

Reported by nicholas a. evans. Thanks!!!

https://github.com/ruby/fiddle/commit/49ea1490df
2022-10-18 17:21:45 +09:00
Sutou Kouhei 08ec656282 [ruby/fiddle] Bump version 2022-10-18 17:21:45 +09:00
Nobuyoshi Nakada 091e3522d7 fiddle: use the old rb_ary_tmp_new() alias
Fiddle is a gem and has the external upstream which supports older
versions of Ruby.
2022-10-18 17:21:45 +09:00
Ben Toews 7db29de008 [ruby/openssl] add document-method for BN#mod_inverse
https://github.com/ruby/openssl/commit/5befde7519
2022-10-17 23:38:35 +09:00
Ben Toews 149cb049f1 [ruby/openssl] add BN#mod_sqrt
https://github.com/ruby/openssl/commit/4619ab3e76
2022-10-17 23:38:34 +09:00
Ben Toews e037731c9f [ruby/openssl] define BIGNUM_2cr macro for BN function that takes context and
returns a BN

https://github.com/ruby/openssl/commit/4d0971c51c
2022-10-17 23:38:34 +09:00
Bart de Water 6166fa612c [ruby/openssl] Call out insecure PKCS #1 v1.5 default padding for RSA
https://github.com/ruby/openssl/commit/fd5eaa6dfc
2022-10-17 16:35:35 +09:00
Samuel Williams aecc470a33 [ruby/openssl] Use default `IO#timeout` if possible.
https://github.com/ruby/openssl/commit/471340f612
2022-10-17 16:35:35 +09:00
Christophe De La Fuente 17998ad3bb [ruby/openssl] Add support to SSL_CTX_set_keylog_callback
- This callback is invoked when TLS key material is generated or
  received, in order to allow applications to store this keying material
  for debugging purposes.
- It is invoked with an `SSLSocket` and a string containing the key
  material in the format used by NSS for its SSLKEYLOGFILE debugging
  output.
- This commit adds the Ruby binding `keylog_cb` and the related tests
- It is only compatible with OpenSSL >= 1.1.1. Even if LibreSSL implements
  `SSL_CTX_set_keylog_callback()` from v3.4.2, it does nothing (see
  648d39f0f0)

https://github.com/ruby/openssl/commit/3b63232cf1
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi e4b1627983 [ruby/openssl] ssl: fix "warning: ‘ctx’ may be used uninitialized"
The code was introduced by https://github.com/ruby/openssl/commit/65530b887e54 ("ssl: enable generating keying
material from SSL sessions", 2022-08-03).

This is harmless, but we should avoid it.

https://github.com/ruby/openssl/commit/f5b82e814b
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi 04bf83d6f7 [ruby/openssl] bump version number to 3.1.0.pre
https://github.com/ruby/openssl/commit/fceb978a5d
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi cd83f5b961 [ruby/openssl] Ruby/OpenSSL 3.0.1
https://github.com/ruby/openssl/commit/e5bbd015dc
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi 15a966a674 [ruby/openssl] Ruby/OpenSSL 2.2.2
https://github.com/ruby/openssl/commit/de8a644bc4
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi 33d30a8675 [ruby/openssl] Ruby/OpenSSL 2.1.4
https://github.com/ruby/openssl/commit/5316241e61
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi b69d41e1c4 [ruby/openssl] pkey/ec: check existence of public key component before exporting
i2d_PUBKEY_bio() against an EC_KEY without the public key component
trggers a null dereference.

This is a regression introduced by commit https://github.com/ruby/openssl/commit/56f0d34d63fb ("pkey:
refactor #export/#to_pem and #to_der", 2017-06-14).

Fixes https://github.com/ruby/openssl/pull/527#issuecomment-1220504524
Fixes https://github.com/ruby/openssl/issues/369#issuecomment-1221554057

https://github.com/ruby/openssl/commit/f6ee0fa4de
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi 0677b2fb87 [ruby/openssl] pkey: restore support for decoding "openssl ecparam -genkey" output
Scan through the input for a private key, then fallback to generic
decoder.

OpenSSL 3.0's OSSL_DECODER supports encoded key parameters. The PEM
header "-----BEGIN EC PARAMETERS-----" is used by one of such encoding
formats. While this is useful for OpenSSL::PKey::PKey, an edge case has
been discovered.

The openssl CLI command line "openssl ecparam -genkey" prints two PEM
blocks in a row, one for EC parameters and another for the private key.
Feeding the whole output into OSSL_DECODER results in only the first PEM
block, the key parameters, being decoded. Previously, ruby/openssl did
not support decoding key parameters and it would decode the private key
PEM block instead.

While the new behavior is technically correct, "openssl ecparam -genkey"
is so widely used that ruby/openssl does not want to break existing
applications.

Fixes https://github.com/ruby/openssl/pull/535

https://github.com/ruby/openssl/commit/d486c82833
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi 4fb2845c7b [ruby/openssl] pkey: clear error queue before each OSSL_DECODER_from_bio() call
Fix potential error queue leak.

https://github.com/ruby/openssl/commit/3992b6f208
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi 10f93a8bd7 [ruby/openssl] pkey/dsa: let PKey::DSA.generate choose appropriate q size
DSA parameters generation via EVP_PKEY_paramgen() will not automatically
adjust the size of q value but uses 224 bits by default unless specified
explicitly. This behavior is different from the now-deprecated
DSA_generate_parameters_ex(), which PKey::DSA.generate used to call.

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

Fixes: https://github.com/ruby/openssl/commit/1800a8d5ebaf ("pkey/dsa: use high level EVP interface to generate parameters and keys", 2020-05-17)

https://github.com/ruby/openssl/commit/0105975a0b
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi 65bba0ef6f [ruby/openssl] hmac: use EVP_PKEY_new_raw_private_key() if available
Current OpenSSL 3.0.x release has a regression with zero-length MAC
keys. While this issue should be fixed in a future release of OpenSSL,
we can use EVP_PKEY_new_raw_private_key() in place of the problematic
EVP_PKEY_new_mac_key() to avoid the issue. OpenSSL 3.0's man page
recommends using it regardless:

> EVP_PKEY_new_mac_key() works in the same way as
> EVP_PKEY_new_raw_private_key().  New applications should use
> EVP_PKEY_new_raw_private_key() instead.

Fixes https://github.com/ruby/openssl/issues/369#issuecomment-1224912710

https://github.com/ruby/openssl/commit/4293f18b1f
2022-10-17 16:35:35 +09:00
Kazuki Yamaguchi bee383d9fe [ruby/openssl] x509*: fix error queue leak in #extensions= and #attributes= methods
X509at_delete_attr() in OpenSSL master puts an error queue entry if
there is no attribute left to delete. We must either clear the error
queue, or try not to call it when the list is already empty.

https://github.com/ruby/openssl/commit/a0c878481f
2022-10-17 16:35:35 +09:00
madblobfish 79543b9a53 [ruby/openssl] ssl: enable generating keying material from SSL sessions
Add OpenSSL::SSL::SSLSocket#export_keying_material to support RFC 5705

https://github.com/ruby/openssl/commit/65530b887e
2022-10-17 16:35:35 +09:00
Nobuhiro IMAI a98096349e [ruby/openssl] Check if the option is an Hash in `pkey_ctx_apply_options0()`
causes SEGV if it is an Array or something like that.

https://github.com/ruby/openssl/commit/ef23525210
2022-10-17 16:35:35 +09:00
Alan Wu 5dae78b9d3 [ruby/openssl] Pass arguments to check macro presence
X509_STORE_get_ex_new_index() is a macro, so passing just its name to
have_func() doesn't detect it. Pass an example call instead.

https://github.com/ruby/openssl/commit/8d264d3e60

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-10-17 16:35:35 +09:00
Alan Wu a211b32180 [ruby/openssl] Check for OpenSSL functions in headers
While building with a custom build of OpenSSL, I noticed in mkmf.log
that all the feature detection checks are done using a program lacking
an OpenSSL header include. `mkmf` retries using a fallback program when
this fails, but that means all the `have_func` calls compile twice when
compiling once should suffice. Example log without this commit:

    have_func: checking for X509_STORE_CTX_get0_cert()... -------------------- yes

    DYLD_FALLBACK_LIBRARY_PATH=.:../.. "clang -o conftest ...
    conftest.c:14:57: error: use of undeclared identifier 'X509_STORE_CTX_get0_cert'
    int t(void) { void ((*volatile p)()); p = (void ((*)()))X509_STORE_CTX_get0_cert; return !p; }
                                                            ^
    1 error generated.
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: /*top*/
     4: extern int t(void);
     5: int main(int argc, char **argv)
     6: {
     7:   if (argc > 1000000) {
     8:     int (* volatile tp)(void)=(int (*)(void))&t;
     9:     printf("%d", (*tp)());
    10:   }
    11:
    12:   return !!argv[argc];
    13: }
    14: int t(void) { void ((*volatile p)()); p = (void ((*)()))X509_STORE_CTX_get0_cert; return !p; }
    /* end */

    DYLD_FALLBACK_LIBRARY_PATH=.:../.. "clang -o conftest ...
    checked program was:
    /* begin */
     1: #include "ruby.h"
     2:
     3: /*top*/
     4: extern int t(void);
     5: int main(int argc, char **argv)
     6: {
     7:   if (argc > 1000000) {
     8:     int (* volatile tp)(void)=(int (*)(void))&t;
     9:     printf("%d", (*tp)());
    10:   }
    11:
    12:   return !!argv[argc];
    13: }
    14: extern void X509_STORE_CTX_get0_cert();
    15: int t(void) { X509_STORE_CTX_get0_cert(); return 0; }
    /* end */

The second compilation succeeds.

Specify the header for each checked function.

https://github.com/ruby/openssl/commit/34ae7d92d0
2022-10-17 16:35:33 +09:00
Kazuki Yamaguchi 63234edf67 openssl: use the old rb_ary_tmp_new() alias
openssl has to support older versions of Ruby. Undo the change in
ext/openssl/ossl_pkey_ec.c by commit efb91ff19b ("Rename
rb_ary_tmp_new to rb_ary_hidden_new", 2022-07-25).
2022-10-17 16:25:51 +09:00
Nobuyoshi Nakada 66a650ec41 [ruby/psych] Fix missing `abort` call
https://github.com/ruby/psych/commit/de2b98c7b7

Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
2022-10-12 20:24:38 +09:00