diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-07-26 16:50:33 +0300 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2015-07-26 16:50:33 +0300 |
commit | 46c072669eb81ed610cc5b3c0dc0c75a143afbb4 (patch) | |
tree | e39a4340db7056d2c4b4118d2b093c5a42ac3f83 /cipher/mac-poly1305.c | |
parent | ada0a7d302cca97b327faaacac7a5d0b8043df88 (diff) | |
download | libgcrypt-46c072669eb81ed610cc5b3c0dc0c75a143afbb4.tar.gz |
Fix undefined behavior wrt memcpy
* cipher/cipher-gcm.c: Do not copy zero bytes from an empty buffer. Let
the function continue to add padding as needed though.
* cipher/mac-poly1305.c: If the caller requested to finish the hash
function without a copy of the result, return immediately.
--
Caught by UndefinedBehaviorSanitizer.
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'cipher/mac-poly1305.c')
-rw-r--r-- | cipher/mac-poly1305.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/cipher/mac-poly1305.c b/cipher/mac-poly1305.c index 76b369ac..b80f87db 100644 --- a/cipher/mac-poly1305.c +++ b/cipher/mac-poly1305.c @@ -260,6 +260,9 @@ poly1305mac_read (gcry_mac_hd_t h, unsigned char *outbuf, size_t *outlen) mac_ctx->marks.tag = 1; } + if (*outlen == 0) + return 0; + if (*outlen <= POLY1305_TAGLEN) buf_cpy (outbuf, mac_ctx->tag, *outlen); else |