Commit 8dd55d9e authored by Richard Levitte's avatar Richard Levitte
Browse files

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: default avatarBen Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/6175)

(cherry picked from commit 0d94212a)
parent aed0ecb9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -188,6 +188,8 @@ static int mem_write(BIO *b, const char *in, int inl)
    }

    BIO_clear_retry_flags(b);
    if (inl == 0)
        return 0;
    blen = bm->length;
    if (BUF_MEM_grow_clean(bm, blen + inl) != (blen + inl))
        goto end;