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()
This commit is contained in:
Vladislav Vaintroub 2019-05-27 17:41:55 +02:00
parent d80065c2e4
commit 7d3a759d42
2 changed files with 5 additions and 1 deletions

View file

@ -60,6 +60,7 @@ public:
}
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)
return MY_AES_OPENSSL_ERROR;
return MY_AES_OK;

View file

@ -1628,8 +1628,11 @@ int Log_event_writer::encrypt_and_write(const uchar *pos, size_t len)
return 1;
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;
if (maybe_write_event_len(dst, dstlen))
return 1;
pos= dst;