Fix issue with non-blocking I/O & record splitting

This commit is contained in:
Manuel Pégourié-Gonnard 2015-01-13 20:56:15 +01:00
parent d5746b36f9
commit a852cf4833
2 changed files with 15 additions and 9 deletions

View File

@ -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 );
}

View File

@ -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" \