Skip to content

Commit c88c3de

Browse files
committed
Only free the read buffers if we're not using them
If we're part way through processing a record, or the application has not released all the records then we should not free our buffer because they are still needed. CVE-2024-4741 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Neil Horman <nhorman@openssl.org> (Merged from #24395) (cherry picked from commit 38690ca)
1 parent 17765d9 commit c88c3de

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ssl/record/methods/tls_common.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,10 @@ int tls_free_buffers(OSSL_RECORD_LAYER *rl)
21292129
/* Read direction */
21302130

21312131
/* If we have pending data to be read then fail */
2132-
if (rl->curr_rec < rl->num_recs || TLS_BUFFER_get_left(&rl->rbuf) != 0)
2132+
if (rl->curr_rec < rl->num_recs
2133+
|| rl->curr_rec != rl->num_released
2134+
|| TLS_BUFFER_get_left(&rl->rbuf) != 0
2135+
|| rl->rstate == SSL_ST_READ_BODY)
21332136
return 0;
21342137

21352138
return tls_release_read_buffer(rl);

0 commit comments

Comments
 (0)