Make sure we remember how much data we sent in the event of a retry
authorMatt Caswell <matt@openssl.org>
Mon, 23 Oct 2023 08:54:16 +0000 (09:54 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 24 Oct 2023 16:37:19 +0000 (17:37 +0100)
If a retry occurs we need to reset s->rlayer.wnum so that next time around
we remember how much data we already sent.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22473)

ssl/record/rec_layer_s3.c

index 260d163a50d932c694ce7006b5884abb3856b8da..845eff9848e5b84525d32715a3ce56b9467bee01 100644 (file)
@@ -294,8 +294,10 @@ int ssl3_write_bytes(SSL *ssl, uint8_t type, const void *buf_, size_t len,
         /* Retry needed */
         i = HANDLE_RLAYER_WRITE_RETURN(s,
                 s->rlayer.wrlmethod->retry_write_records(s->rlayer.wrl));
-        if (i <= 0)
+        if (i <= 0) {
+            s->rlayer.wnum = tot;
             return i;
+        }
         tot += s->rlayer.wpend_tot;
         s->rlayer.wpend_tot = 0;
     } /* else no retry required */
@@ -321,6 +323,7 @@ int ssl3_write_bytes(SSL *ssl, uint8_t type, const void *buf_, size_t len,
         i = ssl->method->ssl_dispatch_alert(ssl);
         if (i <= 0) {
             /* SSLfatal() already called if appropriate */
+            s->rlayer.wnum = tot;
             return i;
         }
         /* if it went, fall through and send more stuff */