From: Richard Levitte Date: Fri, 4 May 2018 12:44:19 +0000 (+0200) Subject: BIO_s_mem() write: Skip early when input length is zero X-Git-Tag: OpenSSL_1_1_0i~128 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8748dccbbab088d9b5484769343121051db78ed9;p=oweals%2Fopenssl.git BIO_s_mem() write: Skip early when input length is zero When the input length is zero, just return zero early. Otherwise, there's a small chance that memory allocation is engaged, fails and returns -1, which is a bit confusing when nothing should be written. Fixes #4782 #4827 Reviewed-by: Ben Kaduk (Merged from https://github.com/openssl/openssl/pull/6175) (cherry picked from commit 0d94212a046e87fafea6e83e8ea2b2a58db49979) --- diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c index ff9a3ebb41..62b01cd5b9 100644 --- a/crypto/bio/bss_mem.c +++ b/crypto/bio/bss_mem.c @@ -212,6 +212,8 @@ static int mem_write(BIO *b, const char *in, int inl) goto end; } BIO_clear_retry_flags(b); + if (inl == 0) + return 0; blen = bbm->readp->length; mem_buf_sync(b); if (BUF_MEM_grow_clean(bbm->buf, blen + inl) == 0)