Skip to content

Commit

Permalink
MDEV-19604 WolfSSL breaks binlog_encryption.binlog_incident
Browse files Browse the repository at this point in the history
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()
  • Loading branch information
vaintroub committed May 27, 2019
1 parent d80065c commit 7d3a759
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions mysys_ssl/my_crypt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MyCTX
}
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;
Expand Down
5 changes: 4 additions & 1 deletion sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7d3a759

Please sign in to comment.