ruby/test/openssl
normal 7513d54659 openssl: avoid undefined behavior on empty SSL_write
SSL_write(3ssl) manpage has this in the WARNINGS section:

       When calling SSL_write() with num=0 bytes to be sent the
       behaviour is undefined.

And indeed, the new test case demonstrates failures when
empty strings are used.  So, match the behavior of IO#write,
IO#write_nonblock, and IO#syswrite by returning zero, as the
OpenSSL::SSL::SSLSocket API already closely mimics the IO one.

* ext/openssl/ossl_ssl.c (ossl_ssl_write_internal):
  avoid undefined behavior
* test/openssl/test_pair.rb (test_write_zero): new test
  [ruby-core:76751] [Bug #12660]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-06 21:50:10 +00:00
..
test_asn1.rb openssl: use ASN1_ENUMERATED_to_BN() if needed 2016-06-09 12:42:08 +00:00
test_bn.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_buffering.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_cipher.rb openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
test_config.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_digest.rb openssl: adjust tests for OpenSSL 1.1.0 2016-06-07 12:20:46 +00:00
test_engine.rb openssl: avoid test failure in test_engine.rb 2016-06-12 04:48:10 +00:00
test_fips.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_hmac.rb openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
test_ns_spki.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_ocsp.rb Refine assertion 2016-06-25 02:32:06 +00:00
test_pair.rb openssl: avoid undefined behavior on empty SSL_write 2016-08-06 21:50:10 +00:00
test_partial_record_read.rb Add frozen_string_literal: false for all files 2015-12-16 05:07:31 +00:00
test_pkcs5.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_pkcs7.rb openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
test_pkcs12.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_pkey_dh.rb openssl: implement initialize_copy method for PKey classes 2016-06-19 09:29:59 +00:00
test_pkey_dsa.rb openssl: implement initialize_copy method for PKey classes 2016-06-19 09:29:59 +00:00
test_pkey_ec.rb openssl: implement initialize_copy method for PKey classes 2016-06-19 09:29:59 +00:00
test_pkey_rsa.rb openssl: implement initialize_copy method for PKey classes 2016-06-19 09:29:59 +00:00
test_random.rb openssl: check existence of RAND_pseudo_bytes() 2016-06-05 12:38:34 +00:00
test_ssl.rb openssl: adjust tests for OpenSSL 1.1.0 2016-06-07 12:20:46 +00:00
test_ssl_session.rb openssl: adjust tests for OpenSSL 1.1.0 2016-06-07 12:20:46 +00:00
test_x509attr.rb openssl: check argument type in OpenSSL::X509::Attribute#value= 2016-05-19 04:12:57 +00:00
test_x509cert.rb openssl: adjust tests for OpenSSL 1.1.0 2016-06-07 12:20:46 +00:00
test_x509crl.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_x509ext.rb openssl: clear OpenSSL error queue before return to Ruby 2016-05-18 04:07:47 +00:00
test_x509name.rb openssl: adjust tests for OpenSSL 1.1.0 2016-06-07 12:20:46 +00:00
test_x509req.rb openssl: adjust tests for OpenSSL 1.1.0 2016-06-07 12:20:46 +00:00
test_x509store.rb openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
utils.rb openssl: fix build with OPENSSL_NO_EC 2016-06-09 10:46:46 +00:00