diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-04-19 15:34:59 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-04-22 16:45:57 +0200 |
commit | 59088414bc3b863a3dc287de76c53464bd7ff6fa (patch) | |
tree | 2aa3c391d223b8b0fbf55658f8a57ca462fde49d /crypto | |
parent | 6b2978406d050b910a889a33f7a0e14b1217976d (diff) | |
download | openssl-59088414bc3b863a3dc287de76c53464bd7ff6fa.tar.gz |
Removed dead code in linebuffer_ctrl()
Fixes Coverity CID 1476284
Also add possible number truncation check.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14928)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bio/bf_lbuf.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c index e9b946fe87..946ff0d23b 100644 --- a/crypto/bio/bf_lbuf.c +++ b/crypto/bio/bf_lbuf.c @@ -232,12 +232,12 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr) } break; case BIO_C_SET_BUFF_SIZE: + if (num > INT_MAX) + return 0; obs = (int)num; p = ctx->obuf; if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size)) { - if (num <= 0) - return 0; - p = OPENSSL_malloc((size_t)num); + p = OPENSSL_malloc((size_t)obs); if (p == NULL) goto malloc_error; } |