diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-02-29 09:58:40 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-02-29 09:58:40 +0100 |
commit | 60f3560ba5f2ccf3adf5ebf7e2eea9907d555cff (patch) | |
tree | d4d58f6ef1543819f5ab4525351ff11278c0ae98 | |
parent | c9a6fd2bf2c8e0b5efbc851460f7917be511d114 (diff) | |
download | gnutls-60f3560ba5f2ccf3adf5ebf7e2eea9907d555cff.tar.gz |
cipher.c: Fixes to prevent undefined behavior (found with libubsan)
-rw-r--r-- | lib/nettle/cipher.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/nettle/cipher.c b/lib/nettle/cipher.c index 602f5c72b7..bf99985338 100644 --- a/lib/nettle/cipher.c +++ b/lib/nettle/cipher.c @@ -578,7 +578,8 @@ wrap_nettle_cipher_setiv(void *_ctx, const void *iv, size_t iv_size) if (ctx->cipher->set_iv) { ctx->cipher->set_iv(ctx->ctx_ptr, iv_size, iv); } else { - memcpy(ctx->iv, iv, iv_size); + if (iv) + memcpy(ctx->iv, iv, iv_size); ctx->iv_size = iv_size; } |