From 8bbf7ef63f95e0ef99e235eab777878d134ed302 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 21 Jul 2022 15:39:39 +0100 Subject: [PATCH] Remove some references to rlayer.rstate This also fixes ssl3_pending while we are at it Reviewed-by: Hugo Landau Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/18132) --- ssl/record/methods/tls_common.c | 10 +++++++++- ssl/record/rec_layer_d1.c | 5 +---- ssl/record/rec_layer_s3.c | 7 +------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ssl/record/methods/tls_common.c b/ssl/record/methods/tls_common.c index 9ae91184956..d414c016f1a 100644 --- a/ssl/record/methods/tls_common.c +++ b/ssl/record/methods/tls_common.c @@ -1265,7 +1265,15 @@ int tls_processed_read_pending(OSSL_RECORD_LAYER *rl) size_t tls_app_data_pending(OSSL_RECORD_LAYER *rl) { - return 0; + size_t i; + size_t num = 0; + + for (i = rl->curr_rec; i num_recs; i++) { + if (rl->rrec[i].type != SSL3_RT_APPLICATION_DATA) + return num; + num += rl->rrec[i].length; + } + return num; } int tls_write_pending(OSSL_RECORD_LAYER *rl) diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c index 50762e07629..a621d089840 100644 --- a/ssl/record/rec_layer_d1.c +++ b/ssl/record/rec_layer_d1.c @@ -379,11 +379,8 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, OPENSSL_cleanse(&(rr->data[rr->off]), n); rr->length -= n; rr->off += n; - if (rr->length == 0) { - /* TODO(RECLAYER): Do something with this? */ - sc->rlayer.rstate = SSL_ST_READ_HEADER; + if (rr->length == 0) ssl_release_record(sc, rr); - } } #ifndef OPENSSL_NO_SCTP /* diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index 30796f2024a..2407efa0e0a 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -1357,13 +1357,8 @@ int ssl3_read_bytes(SSL *ssl, int type, int *recvd_type, unsigned char *buf, OPENSSL_cleanse(&(rr->data[rr->off]), n); rr->length -= n; rr->off += n; - if (rr->length == 0) { - /* TODO(RECLAYER): What to do with this? Is it needed? */ - #if 0 - s->rlayer.rstate = SSL_ST_READ_HEADER; - #endif + if (rr->length == 0) ssl_release_record(s, rr); - } } if (rr->length == 0 || (peek && n == rr->length)) { -- 2.47.2