From 4e1ebda9d9f079ba25638aa8b61393865520c2b1 Mon Sep 17 00:00:00 2001 From: Pauli Date: Mon, 12 Apr 2021 11:36:50 +1000 Subject: [PATCH] bio: add a malloc failed error to BIO_print Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14829) --- crypto/bio/b_print.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c index 08d43d3bd5..ba2c6c5b1f 100644 --- a/crypto/bio/b_print.c +++ b/crypto/bio/b_print.c @@ -835,9 +835,12 @@ doapr_outch(char **sbuffer, *sbuffer = NULL; } else { char *tmpbuf; + tmpbuf = OPENSSL_realloc(*buffer, *maxlen); - if (tmpbuf == NULL) + if (tmpbuf == NULL) { + ERR_raise(ERR_LIB_BIO, ERR_R_MALLOC_FAILURE); return 0; + } *buffer = tmpbuf; } } @@ -929,6 +932,5 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) * been large enough.) */ return -1; - else - return (retlen <= INT_MAX) ? (int)retlen : -1; + return (retlen <= INT_MAX) ? (int)retlen : -1; } -- 2.34.1