提交 0d94212a 编写于 作者: R Richard Levitte

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: NBen Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/6175)
上级 c16ab9dc
...@@ -216,6 +216,8 @@ static int mem_write(BIO *b, const char *in, int inl) ...@@ -216,6 +216,8 @@ static int mem_write(BIO *b, const char *in, int inl)
goto end; goto end;
} }
BIO_clear_retry_flags(b); BIO_clear_retry_flags(b);
if (inl == 0)
return 0;
blen = bbm->readp->length; blen = bbm->readp->length;
mem_buf_sync(b); mem_buf_sync(b);
if (BUF_MEM_grow_clean(bbm->buf, blen + inl) == 0) if (BUF_MEM_grow_clean(bbm->buf, blen + inl) == 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册