Fix the check of BIO_set_write_buffer_size and BIO_set_read_buffer_size
authorPeiwei Hu <jlu.hpw@foxmail.com>
Fri, 2 Dec 2022 08:35:53 +0000 (16:35 +0800)
committerTomas Mraz <tomas@openssl.org>
Mon, 5 Dec 2022 12:05:45 +0000 (13:05 +0100)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19819)

(cherry picked from commit 25d02f333b9a5531fa88db294f69a8347f275858)

apps/s_server.c
crypto/bio/bf_buff.c
crypto/bio/bf_lbuf.c
ssl/ssl_lib.c

index ad352a258896d681042595c279521aab8153c978..8a5ac4c14dc29ea53f7226950de4dd7959da6603 100644 (file)
@@ -3069,7 +3069,7 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
     }
 
     /* lets make the output buffer a reasonable size */
-    if (!BIO_set_write_buffer_size(io, bufsize))
+    if (BIO_set_write_buffer_size(io, bufsize) <= 0)
         goto err;
 
     if ((con = SSL_new(ctx)) == NULL)
@@ -3502,7 +3502,7 @@ static int rev_body(int s, int stype, int prot, unsigned char *context)
         goto err;
 
     /* lets make the output buffer a reasonable size */
-    if (!BIO_set_write_buffer_size(io, bufsize))
+    if (BIO_set_write_buffer_size(io, bufsize) <= 0)
         goto err;
 
     if ((con = SSL_new(ctx)) == NULL)
index cfed63bd72ec84154237ac529188072ec62fecaf..53bd02fe1416d4eec02bdf23fae81a1fbb923c70 100644 (file)
@@ -383,8 +383,8 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
         break;
     case BIO_CTRL_DUP:
         dbio = (BIO *)ptr;
-        if (!BIO_set_read_buffer_size(dbio, ctx->ibuf_size) ||
-            !BIO_set_write_buffer_size(dbio, ctx->obuf_size))
+        if (BIO_set_read_buffer_size(dbio, ctx->ibuf_size) <= 0 ||
+            BIO_set_write_buffer_size(dbio, ctx->obuf_size) <= 0)
             ret = 0;
         break;
     case BIO_CTRL_PEEK:
index 73f121698768750c86f5af3457fbcc81f6104a33..6908e64d365236d2a97c349c35a1e088b09a8604 100644 (file)
@@ -284,7 +284,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
         break;
     case BIO_CTRL_DUP:
         dbio = (BIO *)ptr;
-        if (!BIO_set_write_buffer_size(dbio, ctx->obuf_size))
+        if (BIO_set_write_buffer_size(dbio, ctx->obuf_size) <= 0)
             ret = 0;
         break;
     default:
index 50e4d4b6a2ae68bd88c11b22ce34d27a1d9804fe..f12ad6d034c5d98cad4f43480732d256584b74c6 100644 (file)
@@ -4244,7 +4244,7 @@ int ssl_init_wbio_buffer(SSL *s)
     }
 
     bbio = BIO_new(BIO_f_buffer());
-    if (bbio == NULL || !BIO_set_read_buffer_size(bbio, 1)) {
+    if (bbio == NULL || BIO_set_read_buffer_size(bbio, 1) <= 0) {
         BIO_free(bbio);
         ERR_raise(ERR_LIB_SSL, ERR_R_BUF_LIB);
         return 0;