ruby/ext/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
..
lib openssl: adjust tests for OpenSSL 1.1.0 2016-06-07 12:20:46 +00:00
depend Update dependencies 2016-07-06 05:48:13 +00:00
deprecation.rb openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
extconf.rb openssl: fix build with OpenSSL 1.1.0 and no pkg-config 2016-06-09 06:03:55 +00:00
openssl_missing.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
openssl_missing.h openssl: add 'const's required in OpenSSL master 2016-06-19 05:31:28 +00:00
ossl.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl.h openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
ossl_asn1.c openssl: use ASN1_ENUMERATED_to_BN() if needed 2016-06-09 12:42:08 +00:00
ossl_asn1.h openssl: fix the Year 2038 problem 2016-06-01 12:41:15 +00:00
ossl_bio.c prefer rb_syserr_fail 2015-12-23 08:57:48 +00:00
ossl_bio.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_bn.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_bn.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_cipher.c openssl: support non AES-GCM AEAD ciphers in OpenSSL::Cipher 2016-06-12 05:06:18 +00:00
ossl_cipher.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_config.c * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_config.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_digest.c openssl: use StringValueCStr() where NUL-terminated string is expected 2016-05-23 11:40:07 +00:00
ossl_digest.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_engine.c openssl: adjust tests for OpenSSL 1.1.0 2016-06-07 12:20:46 +00:00
ossl_engine.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_hmac.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_hmac.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_ns_spki.c openssl: use StringValueCStr() where NUL-terminated string is expected 2016-05-23 11:40:07 +00:00
ossl_ns_spki.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_ocsp.c openssl: fix for OpenSSL 1.0.0t 2016-06-29 13:21:54 +00:00
ossl_ocsp.h openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
ossl_pkcs5.c openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
ossl_pkcs5.h * ext/dl/cfunc.c (rb_dlcfunc_call): adjust format. [ruby-dev:31222] 2007-07-15 13:24:39 +00:00
ossl_pkcs7.c openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
ossl_pkcs7.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_pkcs12.c openssl: use StringValueCStr() where NUL-terminated string is expected 2016-05-23 11:40:07 +00:00
ossl_pkcs12.h * ext/openssl/ossl_pkcs12*: Remove svn commit id macro 2015-09-23 13:23:02 +00:00
ossl_pkey.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_pkey.h openssl: add 'const's required in OpenSSL master 2016-06-19 05:31:28 +00:00
ossl_pkey_dh.c openssl: implement initialize_copy method for PKey classes 2016-06-19 09:29:59 +00:00
ossl_pkey_dsa.c openssl: implement initialize_copy method for PKey classes 2016-06-19 09:29:59 +00:00
ossl_pkey_ec.c openssl: implement initialize_copy method for PKey classes 2016-06-19 09:29:59 +00:00
ossl_pkey_rsa.c * ext/digest/md5/md5ossl.h: Remove excess semicolons. 2016-06-28 09:42:29 +00:00
ossl_rand.c openssl: check existence of RAND_pseudo_bytes() 2016-06-05 12:38:34 +00:00
ossl_rand.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_ssl.c openssl: avoid undefined behavior on empty SSL_write 2016-08-06 21:50:10 +00:00
ossl_ssl.h openssl: move SSLSocket#initialize to C extension 2016-05-28 05:00:36 +00:00
ossl_ssl_session.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_version.h * ext/openssl/*: Remove svn commit id macros to make sync easier 2015-09-22 16:12:15 +00:00
ossl_x509.c openssl: fix the Year 2038 problem 2016-06-01 12:41:15 +00:00
ossl_x509.h openssl: fix the Year 2038 problem 2016-06-01 12:41:15 +00:00
ossl_x509attr.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_x509cert.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_x509crl.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_x509ext.c openssl: drop OpenSSL 0.9.6/0.9.7 support 2016-05-25 08:50:03 +00:00
ossl_x509name.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_x509req.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_x509revoked.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ossl_x509store.c openssl: adapt to OpenSSL 1.1.0 opaque structs 2016-06-05 15:35:12 +00:00
ruby_missing.h openssl: allow passing absolute times in OCSP::BasicResponse#add_status 2016-06-19 09:42:30 +00:00