Bug #12660 ยป 0001-openssl-avoid-undefined-behavior-on-empty-SSL_write.patch
| ext/openssl/ossl_ssl.c | ||
|---|---|---|
|     if (ssl_started(ssl)) { | ||
| 	for (;;){ | ||
| 	    nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LENINT(str)); | ||
| 	    int num = RSTRING_LENINT(str); | ||
| 	    /* SSL_write(3ssl) manpage states num == 0 is undefined */ | ||
| 	    if (num == 0) | ||
| 		goto end; | ||
| 	    nwrite = SSL_write(ssl, RSTRING_PTR(str), num); | ||
| 	    switch(ssl_get_error(ssl, nwrite)){ | ||
| 	    case SSL_ERROR_NONE: | ||
| 		goto end; | ||
| test/openssl/test_pair.rb | ||
|---|---|---|
|     } | ||
|   end | ||
|   def test_write_zero | ||
|     ssl_pair {|s1, s2| | ||
|       assert_equal 0, s2.write_nonblock('', exception: false) | ||
|       assert_kind_of Symbol, s1.read_nonblock(1, exception: false) | ||
|       assert_equal 0, s2.syswrite('') | ||
|       assert_kind_of Symbol, s1.read_nonblock(1, exception: false) | ||
|       assert_equal 0, s2.write('') | ||
|       assert_kind_of Symbol, s1.read_nonblock(1, exception: false) | ||
|     } | ||
|   end | ||
|   def tcp_pair | ||
|     host = "127.0.0.1" | ||
|     serv = TCPServer.new(host, 0) | ||
| -  | ||