Skip to content

Commit 7d3a759

Browse files
committed
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()
1 parent d80065c commit 7d3a759

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mysys_ssl/my_crypt.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class MyCTX
6060
}
6161
virtual int update(const uchar *src, uint slen, uchar *dst, uint *dlen)
6262
{
63+
DBUG_ASSERT(src);
6364
if (EVP_CipherUpdate(ctx, dst, (int*)dlen, src, slen) != 1)
6465
return MY_AES_OPENSSL_ERROR;
6566
return MY_AES_OK;

sql/log_event.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,8 +1628,11 @@ int Log_event_writer::encrypt_and_write(const uchar *pos, size_t len)
16281628
return 1;
16291629

16301630
uint dstlen;
1631-
if (encryption_ctx_update(ctx, pos, (uint)len, dst, &dstlen))
1631+
if (len == 0)
1632+
dstlen= 0;
1633+
else if (encryption_ctx_update(ctx, pos, (uint)len, dst, &dstlen))
16321634
goto err;
1635+
16331636
if (maybe_write_event_len(dst, dstlen))
16341637
return 1;
16351638
pos= dst;

0 commit comments

Comments
 (0)