Commit 7d3a759d authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-19604 WolfSSL breaks binlog_encryption.binlog_incident

Log_event_writer::encrypt_and_write() can pass NULL pointer as source buffer
for the encryption. WolfSSL EVP_CipherUpdate(), rightfully rejects this
as invalid parameter.

Fix  Log_event_writer::encrypt_and_write() and check, with assertion,
that src parameterm is sane in MyCTX::update()
parent d80065c2
...@@ -60,6 +60,7 @@ class MyCTX ...@@ -60,6 +60,7 @@ class MyCTX
} }
virtual int update(const uchar *src, uint slen, uchar *dst, uint *dlen) virtual int update(const uchar *src, uint slen, uchar *dst, uint *dlen)
{ {
DBUG_ASSERT(src);
if (EVP_CipherUpdate(ctx, dst, (int*)dlen, src, slen) != 1) if (EVP_CipherUpdate(ctx, dst, (int*)dlen, src, slen) != 1)
return MY_AES_OPENSSL_ERROR; return MY_AES_OPENSSL_ERROR;
return MY_AES_OK; return MY_AES_OK;
......
...@@ -1628,8 +1628,11 @@ int Log_event_writer::encrypt_and_write(const uchar *pos, size_t len) ...@@ -1628,8 +1628,11 @@ int Log_event_writer::encrypt_and_write(const uchar *pos, size_t len)
return 1; return 1;
uint dstlen; uint dstlen;
if (encryption_ctx_update(ctx, pos, (uint)len, dst, &dstlen)) if (len == 0)
dstlen= 0;
else if (encryption_ctx_update(ctx, pos, (uint)len, dst, &dstlen))
goto err; goto err;
if (maybe_write_event_len(dst, dstlen)) if (maybe_write_event_len(dst, dstlen))
return 1; return 1;
pos= dst; pos= dst;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment