@@ -6672,6 +6672,61 @@ static int test_ticket_callbacks(int tst)
6672
6672
return testresult ;
6673
6673
}
6674
6674
6675
+ /*
6676
+ * Test incorrect shutdown.
6677
+ * Test 0: client does not shutdown properly,
6678
+ * server does not set SSL_OP_IGNORE_UNEXPECTED_EOF,
6679
+ * server should get SSL_ERROR_SSL
6680
+ * Test 1: client does not shutdown properly,
6681
+ * server sets SSL_OP_IGNORE_UNEXPECTED_EOF,
6682
+ * server should get SSL_ERROR_ZERO_RETURN
6683
+ */
6684
+ static int test_incorrect_shutdown (int tst )
6685
+ {
6686
+ SSL_CTX * cctx = NULL , * sctx = NULL ;
6687
+ SSL * clientssl = NULL , * serverssl = NULL ;
6688
+ int testresult = 0 ;
6689
+ char buf [80 ];
6690
+ BIO * c2s ;
6691
+
6692
+ if (!TEST_true (create_ssl_ctx_pair (libctx , TLS_server_method (),
6693
+ TLS_client_method (), 0 , 0 ,
6694
+ & sctx , & cctx , cert , privkey )))
6695
+ goto end ;
6696
+
6697
+ if (tst == 1 )
6698
+ SSL_CTX_set_options (sctx , SSL_OP_IGNORE_UNEXPECTED_EOF );
6699
+
6700
+ if (!TEST_true (create_ssl_objects (sctx , cctx , & serverssl , & clientssl ,
6701
+ NULL , NULL )))
6702
+ goto end ;
6703
+
6704
+ if (!TEST_true (create_ssl_connection (serverssl , clientssl ,
6705
+ SSL_ERROR_NONE )))
6706
+ goto end ;
6707
+
6708
+ c2s = SSL_get_rbio (serverssl );
6709
+ BIO_set_mem_eof_return (c2s , 0 );
6710
+
6711
+ if (!TEST_false (SSL_read (serverssl , buf , sizeof (buf ))))
6712
+ goto end ;
6713
+
6714
+ if (tst == 0 && !TEST_int_eq (SSL_get_error (serverssl , 0 ), SSL_ERROR_SSL ) )
6715
+ goto end ;
6716
+ if (tst == 1 && !TEST_int_eq (SSL_get_error (serverssl , 0 ), SSL_ERROR_ZERO_RETURN ) )
6717
+ goto end ;
6718
+
6719
+ testresult = 1 ;
6720
+
6721
+ end :
6722
+ SSL_free (serverssl );
6723
+ SSL_free (clientssl );
6724
+ SSL_CTX_free (sctx );
6725
+ SSL_CTX_free (cctx );
6726
+
6727
+ return testresult ;
6728
+ }
6729
+
6675
6730
/*
6676
6731
* Test bi-directional shutdown.
6677
6732
* Test 0: TLSv1.2
@@ -7685,6 +7740,7 @@ int setup_tests(void)
7685
7740
ADD_ALL_TESTS (test_ssl_get_shared_ciphers , OSSL_NELEM (shared_ciphers_data ));
7686
7741
ADD_ALL_TESTS (test_ticket_callbacks , 16 );
7687
7742
ADD_ALL_TESTS (test_shutdown , 7 );
7743
+ ADD_ALL_TESTS (test_incorrect_shutdown , 2 );
7688
7744
ADD_ALL_TESTS (test_cert_cb , 6 );
7689
7745
ADD_ALL_TESTS (test_client_cert_cb , 2 );
7690
7746
ADD_ALL_TESTS (test_ca_names , 3 );
0 commit comments