BIO_s_mem() write: Skip early when input length is zero
authorRichard Levitte <levitte@openssl.org>
Fri, 4 May 2018 12:44:19 +0000 (14:44 +0200)
committerRichard Levitte <levitte@openssl.org>
Fri, 4 May 2018 22:19:17 +0000 (00:19 +0200)
commit8dd55d9ee107337460e6a35b4ece234b4475e12d
tree1800afd2a9368d30ad7ad24f00f6f0f1b22b3b40
parentaed0ecb97c2d5329b5b5728c1e74fa63ce58ca8f
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 <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/6175)

(cherry picked from commit 0d94212a046e87fafea6e83e8ea2b2a58db49979)
crypto/bio/bss_mem.c