summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2017-11-06 16:52:06 +0000
committerMatt Caswell <matt@openssl.org>2017-11-07 11:14:00 +0000
commit2df7971728ddd388a77de56acc01e4bab37796bb (patch)
tree107546819cd1fc9409117c4bb8fbe7f7bf472ea2 /ssl
parent77543471c709089d3845f6bdcf13fa4557ec57dc (diff)
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 <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4686)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/record/rec_layer_s3.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c
index 5945d18748..95026c6e57 100644
--- a/ssl/record/rec_layer_s3.c
+++ b/ssl/record/rec_layer_s3.c
@@ -1133,8 +1133,16 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
if (recvd_type != NULL)
*recvd_type = SSL3_RECORD_get_type(rr);
- if (len <= 0)
- return (len);
+ if (len <= 0) {
+ /*
+ * Mark a zero length record as read. This ensures multiple calls to
+ * SSL_read() with a zero length buffer will eventually cause
+ * SSL_pending() to report data as being available.
+ */
+ if (SSL3_RECORD_get_length(rr) == 0)
+ SSL3_RECORD_set_read(rr);
+ return len;
+ }
read_bytes = 0;
do {