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:04:18 +0000 (13:04 +0100)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19819)

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

index 46af6b87dad7f2cb97a274225f5426ed0bf959f3..0b794960f92cc0a712fe6ea979982bf8946d3235 100644 (file)
@@ -3131,7 +3131,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)
@@ -3560,7 +3560,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 fe0ca92225a5bde6afe6089b14eb7717f2da91b0..b94c58c0a38157edbc07ce0e1855801f3fa66a86 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 8854b4144cbaa1ff836279b958451e121871cbaf..eb23c886476033edc3cd5efe9b05fb29aa8b8360 100644 (file)
@@ -281,7 +281,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 118c4d95ba5c5c17920eea076ed616eceb5c4644..77abe3dc27251027778e03af3505fe6cee857e61 100644 (file)
@@ -4816,7 +4816,7 @@ int ssl_init_wbio_buffer(SSL_CONNECTION *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;