diff --git a/library/ssl_tls.c b/library/ssl_tls.c index ac740585c..6b9df3369 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -4846,19 +4846,16 @@ int ssl_write( ssl_context *ssl, const unsigned char *buf, size_t len ) return( ssl_write_real( ssl, buf, len ) ); } - if( ssl->split_done != 1 ) + if( ssl->split_done == 0 ) { - ssl->split_done = 1; - if( ( ret = ssl_write_real( ssl, buf, 1 ) ) < 0 ) + if( ( ret = ssl_write_real( ssl, buf, 1 ) ) <= 0 ) return( ret ); + ssl->split_done = 1; } - if( ssl->split_done == 1 ) - { - ssl->split_done = 0; - if( ( ret = ssl_write_real( ssl, buf + 1, len - 1 ) ) < 0 ) - return( ret ); - } + if( ( ret = ssl_write_real( ssl, buf + 1, len - 1 ) ) <= 0 ) + return( ret ); + ssl->split_done = 0; return( ret + 1 ); } diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index cd4f6a67f..51c3fd0c6 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -718,6 +718,15 @@ run_test "CBC Record splitting: TLS 1.0, splitting disabled" \ -S "Read from client: 1 bytes read" \ -S "122 bytes read" +run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \ + "$P_SRV nbio=2" \ + "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \ + request_size=123 force_version=tls1" \ + 0 \ + -S "Read from client: 123 bytes read" \ + -s "Read from client: 1 bytes read" \ + -s "122 bytes read" + # Tests for Session Tickets run_test "Session resume using tickets: basic" \