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

8909 Коммитов

Автор SHA1 Сообщение Дата
Jun Aruga b5d0374635
[ruby/openssl] Fix LIBRESSL_VERSION_NUMBER document mistake.
* Fix the wrong man reference.
* According to the LIBRESSL_VERSION_NUMBER(3), the value always ends with 00f.

```
$ man -M /home/jaruga/.local/libressl-6650dce/share/man/ 3 LIBRESSL_VERSION_NUMBER
...
DESCRIPTION
     OPENSSL_VERSION_NUMBER and LIBRESSL_VERSION_NUMBER are numeric release version
     identifiers.  The first two digits contain the major release number, the third and
     fourth digits the minor release number, and the fifth and sixth digits the fix re‐
     lease number.  For OpenSSL, the seventh and eight digits contain the patch release
     number and the final digit is 0 for development, 1 to e for betas 1 to 14, or f
     for release.  For LibreSSL, OPENSSL_VERSION_NUMBER is always 0x020000000, and
     LIBRESSL_VERSION_NUMBER always ends with 00f.
```

https://github.com/ruby/openssl/commit/296c859d18
2023-08-25 18:34:47 +09:00
卜部昌平 d9cba2fc74 include missing header 2023-08-25 17:27:53 +09:00
卜部昌平 12ec1fb2b1 use configure-detected sanity of _Alignof
This is actually already checked in (Ruby's) configure.
2023-08-25 17:27:53 +09:00
卜部昌平 eec85a6309 tool/update-deps --fix 2023-08-25 17:27:53 +09:00
Nobuyoshi Nakada 412defc7ad [ruby/io-console] Get rid of address of an rvalue on TruffleRuby
https://github.com/ruby/io-console/commit/653c1cd33f
2023-08-18 03:55:05 +00:00
Nobuyoshi Nakada 818ba30ee9 [ruby/io-console] Avoid the influence of special variable `$/`
https://github.com/ruby/io-console/commit/5f71354332
2023-08-18 03:55:04 +00:00
Nobuyoshi Nakada cff8058701 [ruby/io-console] Ensure to put a newline after password
https://github.com/ruby/io-console/commit/15e36af171
2023-08-18 03:55:04 +00:00
Nobuyoshi Nakada 528da4347c [ruby/io-console] Flush after prompt
https://github.com/ruby/io-console/commit/040a1d6259
2023-08-18 03:55:03 +00:00
Nobuyoshi Nakada 540cf43205 [ruby/io-console] Enable `getpass` methods always
https://github.com/ruby/io-console/commit/57f9649df4
2023-08-18 03:55:02 +00:00
Nobuyoshi Nakada 1bbce42964 [ruby/io-console] [DOC] Remove a trailing space from the prompt too
https://github.com/ruby/io-console/commit/85a155f25f
2023-08-18 01:17:03 +00:00
Nobuyoshi Nakada 1107cfd077 [ruby/io-console] * remove trailing spaces [ci skip]
https://github.com/ruby/io-console/commit/a0544eb74f
2023-08-18 01:15:00 +00:00
Olivier Lacan 43802a088e [ruby/io-console] [DOC] IO::console.getpass usage example
There were no clear example of this very useful method's usage anywhere
in the IO or IO::Console docs, which was a shame.

https://github.com/ruby/io-console/commit/4d324586a8
2023-08-18 01:02:42 +00:00
Jun Aruga f1df062944 [ruby/openssl] Enhance printing OpenSSL versions.
* Updated the `OpenSSL::OPENSSL_VERSION_NUMBER` comment explaining the format.
* Added the `OpenSSL::LIBRESSL_VERSION_NUMBER` to print LibreSSL version number,
  in the case that Ruby OpenSSL binding is compiled with LibreSSL. Note
  `test/openssl/utils.rb#libressl?` is not using this value in it for now.
* Update `rake debug` to print the values in a readable way, adding
  `OpenSSL::OPENSSL_VERSION_NUMBER` and `OpenSSL::LIBRESSL_VERSION_NUMBER`.

https://github.com/ruby/openssl/commit/d19e6360ed
2023-08-16 14:48:42 +09:00
Kazuki Yamaguchi 12bdacdca5 [ruby/openssl] Include "additional data" message in OpenSSL errors
Error entries in the OpenSSL error queue may contain additional
contextual information associated with the error, which can be helpful
when debugging.

This "additional data" is currently only printed to stderr when
OpenSSL.debug is enabled. Let's include this in the exception messages
raised with ossl_raise(), too.

	$ ruby -Ilib -ropenssl -e'OpenSSL.debug=true; OpenSSL::SSL::SSLContext.new.ecdh_curves="P-256:not-a-curve"'
	-e:1: warning: error on stack: error:0A080106:SSL routines:gid_cb:passed invalid argument (group 'not-a-curve' cannot be set)
	-e:1:in `ecdh_curves=': passed invalid argument (group 'not-a-curve' cannot be set) (OpenSSL::SSL::SSLError)
		from -e:1:in `<main>'

https://github.com/ruby/openssl/commit/1c5bbdd68e
2023-08-16 14:48:41 +09:00
Kazuki Yamaguchi 01d368e7b0 [ruby/openssl] ssl: raise SSLError if loading ca_file or ca_path fails
When compiled with OpenSSL <= 1.1.1, OpenSSL::SSL::SSLContext#setup
does not raise an exception on an error return from
SSL_CTX_load_verify_locations(), but instead only prints a verbose-mode
warning. This is not helpful since it very likely indicates an actual
error, such as the specified file not being readable.

Also, OpenSSL's error queue is not correctly cleared:

	$ ruby -w -ropenssl -e'OpenSSL.debug=true; ctx=OpenSSL::SSL::SSLContext.new; ctx.ca_file="bad-path"; ctx.setup; pp OpenSSL.errors'
	-e:1: warning: can't set verify locations
	["error:02001002:system library:fopen:No such file or directory",
	 "error:2006D080:BIO routines:BIO_new_file:no such file",
	 "error:0B084002:x509 certificate routines:X509_load_cert_crl_file: system lib"]

The behavior is currently different when compiled with OpenSSL >= 3.0:
SSLError is raised if SSL_CTX_load_verify_file() or
SSL_CTX_load_verify_dir() fails.

This inconsistency was unintentionally introduced by commit https://github.com/ruby/openssl/commit/5375a55ffc35
("ssl: use SSL_CTX_load_verify_{file,dir}() if available", 2020-02-22).
However, raising SSLError seems more appropriate in this situation.
Let's adjust the OpenSSL <= 1.1.1 code so that it behaves the same way
as the OpenSSL >= 3.0 code currently does.

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

https://github.com/ruby/openssl/commit/7eb10f7b75
2023-08-16 14:48:41 +09:00
Jun Aruga 8dd5c20224 [ruby/openssl] Raise an error when the specified OpenSSL library directory doesn't exist.
OpenSSL built from the source creates the library directory to the
`/path/to/openssl_dir/lib64` as a default.
In the case, the `bundle exec rake compile -- --with-openssl-dir=<openssl_dir>`
cannot compile with the lib64 directory, and may compile with system OpenSSL's
libraries unintentionally. This commit is to check this case to avoid linking
with an unintentional library directory.

https://github.com/ruby/openssl/commit/ca54087462
2023-08-16 14:48:41 +09:00
Kazuki Yamaguchi 0eaee5c000 [ruby/openssl] [DOC] enhance RDoc for exporting pkeys
Describe the behavior of OpenSSL::PKey::{DH,DSA,EC,RSA}#to_pem
and #to_der more clearly. They return a different result depending on
whether the pkey is a public or private key. This was not documented
adequately.

Also, suggest the use of OpenSSL::PKey::PKey#private_to_pem
and #public_to_pem instead, if possible.

https://github.com/ruby/openssl/commit/d22769af8f
2023-08-16 14:48:40 +09:00
Kazuki Yamaguchi fae6fd07fe [ruby/openssl] [DOC] prefer PKey#private_to_pem and #public_to_pem in RDoc
Suggest the use of OpenSSL::PKey::PKey#private_to_pem and #public_to_pem
in the top-level documentation. For new programs, these are recommended
over OpenSSL::PKey::RSA#export (also aliased as #to_s and #to_pem)
unless there is a specific reason to use it, i.e., unless the PKCS#1
output format specifically is required.

The output format of OpenSSL::PKey::RSA#export depends on whether the
key is a public key or a private key, which is very counter-intuitive.

Additionally, when called with arguments to encrypt a private key, as in
this example, OpenSSL's own, non-standard format is used. The man page
of PEM_write_bio_PrivateKey_traditional(3) in OpenSSL 1.1.1 or later
states that it "should only be used for compatibility with legacy
programs".

https://github.com/ruby/openssl/commit/56312038d6
2023-08-16 14:48:40 +09:00
Kazuki Yamaguchi 4541cd4cba [ruby/openssl] [DOC] prefer "password" to "passphrase"
Let's consistently use the word "password". Although they are considered
synonymous, the mixed usage in the rdoc can cause confusion.

OpenSSL::KDF.scrypt is an exception. This is because RFC 7914 refers to
the input parameter as "passphrase".

https://github.com/ruby/openssl/commit/06d67640e9
2023-08-16 14:48:40 +09:00
Kazuki Yamaguchi cb344e4e25 [ruby/openssl] ssl: adjust "certificate verify failed" error on SSL_ERROR_SYSCALL
Enrich SSLError's message with the low-level certificate verification
result, even if SSL_get_error() returns SSL_ERROR_SYSCALL. This is
currently done on SSL_ERROR_SSL only.

According to the man page of SSL_get_error(), SSL_ERROR_SYSCALL may be
returned for "other errors, check the error queue for details". This
apparently means we have to treat SSL_ERROR_SYSCALL, if errno is not
set, as equivalent to SSL_ERROR_SSL.

https://github.com/ruby/openssl/commit/5113777e82
2023-08-16 14:48:39 +09:00
Kazuki Yamaguchi 66a70582f4 [ruby/openssl] ssl: adjust styles of ossl_start_ssl()
Expand tabs, insert some spaces, and adjust indentation of switch-case
to match Ruby's style.

https://github.com/ruby/openssl/commit/10833aa8f6
2023-08-16 14:48:39 +09:00
Sorah Fukumori d2864ca330 [ruby/zlib] Zlib.gunzip should not fail with utf-8 strings
(https://github.com/ruby/zlib/pull/55)

zstream_discard_input was encoding and character-aware when given input is user-provided, so this discards `len` chars instead of `len` bytes.

Also Zlib.gunzip explains in its rdoc that it is equivalent with the following code, but this doesn't fail for UTF-8 String.

```ruby
string = %w[1f8b0800c28000000003cb48cdc9c9070086a6103605000000].pack("H*").force_encoding('UTF-8')
sio = StringIO.new(string)
p gz.read #=> "hello"
gz&.close
p Zlib.gunzip(string) #=> Zlib::DataError
```

Reported and discovered by eagletmt at https://twitter.com/eagletmt/status/1689692467929694209

https://github.com/ruby/zlib/commit/c5e58bc62a
2023-08-10 20:12:21 +00:00
Jean byroot Boussier fd8dd71996
Implement StringIO#pread (#56)
Both for being closer to real IOs and also because it's a convenient API
in multithreaded scenarios.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-08-02 18:18:17 +09:00
Sutou Kouhei fe25527781 [ruby/fiddle] Include stdbool.h explicitly
https://github.com/ruby/fiddle/commit/c313a74632
2023-08-02 18:17:20 +09:00
Sutou Kouhei 673f4493b0 [ruby/fiddle] Include stdbool.h explicitly
https://github.com/ruby/fiddle/commit/69ff680bf6
2023-08-02 18:17:19 +09:00
Sutou Kouhei 15e8cf7ad9 [ruby/fiddle] Add support for bool
GitHub: fix https://github.com/ruby/fiddle/pull/130

Reported by Benoit Daloze. Thanks!!!

https://github.com/ruby/fiddle/commit/bc6c66bbb9
2023-08-02 18:17:18 +09:00
Sutou Kouhei 10588fa121 [ruby/fiddle] Use ifdef
https://github.com/ruby/fiddle/commit/6cdf53726d
2023-08-02 18:17:16 +09:00
Peter Zhu 91e13a5207 [ruby/strscan] Fix indentation in strscan.c
[ci skip]
2023-07-28 10:12:52 -04:00
Peter Zhu 7193b404a1 Add function rb_reg_onig_match
rb_reg_onig_match performs preparation, error handling, and cleanup for
matching a regex against a string. This reduces repetitive code and
removes the need for StringScanner to access internal data of regex.
2023-07-27 13:33:40 -04:00
Peter Zhu e27eab2f85 [ruby/strscan] Sync missed commit
Syncs commit ruby/strscan@76b377a5d8.
2023-07-27 09:42:42 -04:00
Benoit Daloze 14d16bdb1a [ruby/openssl] Always respect the openssl prefix chosen by truffle/openssl-prefix on TruffleRuby
* See https://github.com/ruby/openssl/issues/650#issuecomment-1645699608

https://github.com/ruby/openssl/commit/ca738e7e13
2023-07-24 15:08:54 +09:00
Nobuyoshi Nakada 19486ebd72 [flori/json] Re-generate parser.c
https://github.com/flori/json/commit/82a75ba98e
2023-07-19 00:02:58 +09:00
Nobuyoshi Nakada 768668a4de [flori/json] Remove unnecessary code
In `JSON#generate` and `JSON#fast_generate`:

- When the given `opts` is a `JSON::State` the variable is set to
  `nil`.
- But it will be never used as the next `if` blocks will not be
  executed.
- `JSON::State#configure` does the conversion to `Hash`, the
  conversions in the `if` block are just duplication.
- `JSON::State.new` does the same thing with `configure` when an
  argument is given.

https://github.com/flori/json/commit/5d9ab87f8e
2023-07-19 00:02:58 +09:00
Nobuyoshi Nakada 104089ce02 [flori/json] [DOC] Remove duplicate sentence
https://github.com/flori/json/commit/ed242667b4
2023-07-19 00:02:58 +09:00
Nobuyoshi Nakada f1f84ca71c [flori/json] Remove `HAVE_RB_SCAN_ARGS_OPTIONAL_HASH` check
This macro is defined since ruby 2.1, which is older than the required
ruby version.

https://github.com/flori/json/commit/dd1d54e78a
2023-07-19 00:02:58 +09:00
Hiroshi SHIBATA 56c8dab468 [flori/json] Skip BigDecimal tests when it's missing to load
https://github.com/flori/json/commit/3dd36c6077
2023-07-18 12:25:55 +09:00
Dimitar Haralanov 9977462fd9 [flori/json] Rename JSON::ParseError to JSON:ParserError
https://github.com/flori/json/commit/20b80ca317
2023-07-18 12:25:54 +09:00
yui-knk 0a570a0069 Fix `#line` directive filename of ripper.c
Before:

```c
/* First part of user prologue.  */
#line 14 "parse.y"
```

After:

```c
/* First part of user prologue.  */
#line 14 "ripper.y"
```
2023-07-16 19:27:08 +09:00
Nobuyoshi Nakada 5c77402d88
Fix null pointer access in Ripper#initialize
In `rb_ruby_ripper_parser_allocate`, `r->p` is NULL between creating
`self` and `parser_params` assignment.  As GC can happen there, the
typed-data functions for it need to consider the case.
2023-07-16 15:41:10 +09:00
yui-knk 82cd70ef93 Use functions defined by parser_st.c to reduce dependency on st.c 2023-07-15 12:50:40 +09:00
Nobuyoshi Nakada 9c1fe9064c
[Feature #19757] Add new API `rb_data_define` 2023-07-13 17:55:55 +09:00
Nobuyoshi Nakada 47cb789332 [ruby/etc] Declare `getlogin` even if unistd.h is not available
Although MinGW provides this header but not the function, Windows
version ruby provides the function.

https://github.com/ruby/etc/commit/f7fa1884fa
2023-07-12 16:22:54 +00:00
Kazuki Yamaguchi f4bf80623f [ruby/openssl] [DOC] remove top-level example for
OpenSSL::Cipher#pkcs5_keyivgen
(https://github.com/ruby/openssl/pull/647)

OpenSSL::Cipher#pkcs5_keyivgen should only be used when it is
absolutely necessary for compatibility with ancient applications.
Having an example can be misleading. We already have another example
for OpenSSL::Cipher in which PBKDF2 is used to derive a key.

As described in the rdoc of OpenSSL::Cipher#pkcs5_keyivgen, it is
compatible with PKCS#5 PBES1 (PKCS#5 v1.5) only when used in combination
of a hash function MD2, MD5, or SHA-1, and a cipher DES-CBC or RC2-CBC.
This example uses MD5 as the hash function and combines it with AES.
This is considered insecure and also using a non-standard technique to
derive longer keys.

https://github.com/ruby/openssl/commit/e379cc0cca
2023-07-12 23:40:58 +09:00
Ryo Kajiwara 4b6d667c63 [ruby/openssl] Add support for raw private/public keys
(https://github.com/ruby/openssl/pull/646)

Add OpenSSL::PKey.new_raw_private_key, #raw_private_key and public
equivalents. These methods are useful for importing and exporting keys
that support "raw private/public key". Currently, OpenSSL implements
X25519/X448 and Ed25519/Ed448 keys.

[rhe: rewrote commit message]

https://github.com/ruby/openssl/commit/3f29525618

Co-authored-by: Bart de Water <bartdewater@gmail.com>
2023-07-12 23:40:58 +09:00
Nobuyoshi Nakada 4fced78605 [ruby/etc] Chec if the target file exists, not "depend" file
https://github.com/ruby/etc/commit/b95ddef386
2023-07-12 14:18:40 +00:00
Nobuyoshi Nakada 2fa77fb82d [ruby/etc] Fix for srcdir with spaces
Fixes https://github.com/ruby/etc/pull/22.
Build failure when the ruby installed directory name contains spaces.

https://github.com/ruby/etc/commit/1ab19d5815
2023-07-12 14:18:39 +00:00
Nobuyoshi Nakada efd8ea366b [ruby/etc] Declare `getlogin` only if unistd.h is not available
https://github.com/ruby/etc/commit/365398ea47
2023-07-12 14:18:39 +00:00
Nobuyoshi Nakada c8d0470bb0
Use `File::NULL` instead of hard coded null device names 2023-07-10 19:21:47 +09:00
yui-knk b2bccf053b Include ripper.h into `$distcleanfiles` 2023-07-09 13:02:25 +09:00
cryptogopher 5f07f78e86 [ruby/bigdecimal] Update to_s doc examples
https://github.com/ruby/bigdecimal/commit/8a94a29cf1
2023-07-05 20:15:53 +00:00