From 544758738dad2c0db6b236ba395905e671a252e8 Mon Sep 17 00:00:00 2001 From: Peiwei Hu Date: Fri, 2 Dec 2022 16:35:53 +0800 Subject: Fix the check of BIO_set_write_buffer_size and BIO_set_read_buffer_size Reviewed-by: Hugo Landau Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/19819) (cherry picked from commit 25d02f333b9a5531fa88db294f69a8347f275858) --- apps/s_server.c | 4 ++-- crypto/bio/bf_buff.c | 4 ++-- crypto/bio/bf_lbuf.c | 2 +- ssl/ssl_lib.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/s_server.c b/apps/s_server.c index cfd3deb1be..2b0b6ba381 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -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) @@ -3505,7 +3505,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) diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c index cfed63bd72..53bd02fe14 100644 --- a/crypto/bio/bf_buff.c +++ b/crypto/bio/bf_buff.c @@ -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: diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c index 73f1216987..6908e64d36 100644 --- a/crypto/bio/bf_lbuf.c +++ b/crypto/bio/bf_lbuf.c @@ -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: diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 75ef563f1f..214884b0f1 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -4243,7 +4243,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; -- cgit v1.2.3