Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c47d35

Browse files
committed
Mark a zero length record as read
If SSL_read() is called with a zero length buffer, and we read a zero length record then we should mark that record as read. Reviewed-by: Rich Salz <[email protected]> (Merged from openssl#4685)
1 parent 018632a commit 1c47d35

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ssl/record/rec_layer_s3.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,8 +1305,16 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
13051305
if (recvd_type != NULL)
13061306
*recvd_type = SSL3_RECORD_get_type(rr);
13071307

1308-
if (len == 0)
1308+
if (len == 0) {
1309+
/*
1310+
* Mark a zero length record as read. This ensures multiple calls to
1311+
* SSL_read() with a zero length buffer will eventually cause
1312+
* SSL_pending() to report data as being available.
1313+
*/
1314+
if (SSL3_RECORD_get_length(rr) == 0)
1315+
SSL3_RECORD_set_read(rr);
13091316
return 0;
1317+
}
13101318

13111319
totalbytes = 0;
13121320
do {

0 commit comments

Comments
 (0)