bio: pass flags on BIO_ctrl to make flush retriable
authorihciah <ihciah@gmail.com>
Thu, 11 May 2023 09:30:14 +0000 (09:30 +0000)
committerTodd Short <todd.short@me.com>
Fri, 4 Aug 2023 14:30:58 +0000 (10:30 -0400)
Co-authored-by: suikammd <suikalala@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21298)

crypto/bio/bf_buff.c
crypto/bio/bf_lbuf.c
crypto/comp/c_brotli.c
crypto/comp/c_zlib.c
crypto/comp/c_zstd.c
crypto/evp/bio_b64.c
crypto/evp/bio_enc.c
crypto/evp/bio_ok.c

index b94c58c0a38157edbc07ce0e1855801f3fa66a86..bad465c07290f6601bd53b8b2ac0a72947a2b052 100644 (file)
@@ -360,6 +360,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
             return 0;
         if (ctx->obuf_len <= 0) {
             ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
+            BIO_copy_next_retry(b);
             break;
         }
 
@@ -380,6 +381,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
             }
         }
         ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
+        BIO_copy_next_retry(b);
         break;
     case BIO_CTRL_DUP:
         dbio = (BIO *)ptr;
index eb23c886476033edc3cd5efe9b05fb29aa8b8360..170e375e7f8d9642460776d8a77eb201268e14ba 100644 (file)
@@ -259,6 +259,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
             return 0;
         if (ctx->obuf_len <= 0) {
             ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
+            BIO_copy_next_retry(b);
             break;
         }
 
@@ -278,6 +279,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
             }
         }
         ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
+        BIO_copy_next_retry(b);
         break;
     case BIO_CTRL_DUP:
         dbio = (BIO *)ptr;
index 2d98b63a8931d9a0f893e06508fd140eba804556..df63a43b417d9dfb6ae8367edb8458ec83c0e4c4 100644 (file)
@@ -716,8 +716,10 @@ static long bio_brotli_ctrl(BIO *b, int cmd, long num, void *ptr)
 
     case BIO_CTRL_FLUSH:
         ret = bio_brotli_flush(b);
-        if (ret > 0)
+        if (ret > 0) {
             ret = BIO_flush(next);
+            BIO_copy_next_retry(b);
+        }
         break;
 
     case BIO_C_SET_BUFF_SIZE:
index 90a1840ecd5f0572617986b1234b7356e71e7efc..52f2e26a73f7e9a258acc87eaafe1021a190b55a 100644 (file)
@@ -640,8 +640,10 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
 
     case BIO_CTRL_FLUSH:
         ret = bio_zlib_flush(b);
-        if (ret > 0)
+        if (ret > 0) {
             ret = BIO_flush(next);
+            BIO_copy_next_retry(b);
+        }
         break;
 
     case BIO_C_SET_BUFF_SIZE:
index 17dc0f64a417db10187b2037ca37c63bc007071b..7f6c5cc72c21415d3f090c4fa95fdef699644250 100644 (file)
@@ -762,8 +762,10 @@ static long bio_zstd_ctrl(BIO *b, int cmd, long num, void *ptr)
 
     case BIO_CTRL_FLUSH:
         ret = bio_zstd_flush(b);
-        if (ret > 0)
+        if (ret > 0) {
             ret = BIO_flush(next);
+            BIO_copy_next_retry(b);
+        }
         break;
 
     case BIO_C_SET_BUFF_SIZE:
index 0292c678c91ae4f1b0e3720500adfb94206a6f04..4822d37ea4bece2ca00ffd90d8a54d80ff596a67 100644 (file)
@@ -496,6 +496,7 @@ static long b64_ctrl(BIO *b, int cmd, long num, void *ptr)
         }
         /* Finally flush the underlying BIO */
         ret = BIO_ctrl(next, cmd, num, ptr);
+        BIO_copy_next_retry(b);
         break;
 
     case BIO_C_DO_STATE_MACHINE:
index a284b6d9ebffafd212837e19427141195a21f3d2..4a2e5a8303fe9d9f208298d203fe91309011d029 100644 (file)
@@ -360,6 +360,7 @@ static long enc_ctrl(BIO *b, int cmd, long num, void *ptr)
 
         /* Finally flush the underlying BIO */
         ret = BIO_ctrl(next, cmd, num, ptr);
+        BIO_copy_next_retry(b);
         break;
     case BIO_C_GET_CIPHER_STATUS:
         ret = (long)ctx->ok;
index a07c9c599830279dfb1ab97d03f77e1613ddd681..a72acfb39be962760d76dd5a9f2ed6a534cba66e 100644 (file)
@@ -372,6 +372,7 @@ static long ok_ctrl(BIO *b, int cmd, long num, void *ptr)
 
         /* Finally flush the underlying BIO */
         ret = BIO_ctrl(next, cmd, num, ptr);
+        BIO_copy_next_retry(b);
         break;
     case BIO_C_DO_STATE_MACHINE:
         BIO_clear_retry_flags(b);