summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-02-29 09:58:40 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-02-29 09:58:40 +0100
commit60f3560ba5f2ccf3adf5ebf7e2eea9907d555cff (patch)
treed4d58f6ef1543819f5ab4525351ff11278c0ae98
parentc9a6fd2bf2c8e0b5efbc851460f7917be511d114 (diff)
downloadgnutls-60f3560ba5f2ccf3adf5ebf7e2eea9907d555cff.tar.gz
cipher.c: Fixes to prevent undefined behavior (found with libubsan)
-rw-r--r--lib/nettle/cipher.c3
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;
}