diff options
author | Gary Lockyer <gary@catalyst.net.nz> | 2019-05-24 11:00:05 +1200 |
---|---|---|
committer | Gary Lockyer <gary@samba.org> | 2019-05-27 01:29:48 +0000 |
commit | 412afb2aef100e09eb433b8f0cae064fc2a736b7 (patch) | |
tree | 2a3eedf4bbb4bc450d31652a7d765762237c4807 /lib/crypto | |
parent | da87fa998ab71328f30bcdf5b41aee8675aee48a (diff) | |
download | samba-412afb2aef100e09eb433b8f0cae064fc2a736b7.tar.gz |
Fix ubsan null pointer passed as argument 2
Fix ubsan warning null pointer passed as argument 2 when the source
pointer is NULL. The calls to memcpy are now guarded by an
if (len > 0)
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Mon May 27 01:29:48 UTC 2019 on sn-devel-184
Diffstat (limited to 'lib/crypto')
-rw-r--r-- | lib/crypto/aes_cmac_128.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/crypto/aes_cmac_128.c b/lib/crypto/aes_cmac_128.c index e5e489ec70d..e7bf030c92a 100644 --- a/lib/crypto/aes_cmac_128.c +++ b/lib/crypto/aes_cmac_128.c @@ -69,10 +69,12 @@ void aes_cmac_128_update(struct aes_cmac_128_context *ctx, if (ctx->last_len < AES_BLOCK_SIZE) { size_t len = MIN(AES_BLOCK_SIZE - ctx->last_len, msg_len); - memcpy(&ctx->last[ctx->last_len], msg, len); - msg += len; - msg_len -= len; - ctx->last_len += len; + if (len > 0) { + memcpy(&ctx->last[ctx->last_len], msg, len); + msg += len; + msg_len -= len; + ctx->last_len += len; + } } if (msg_len == 0) { |