diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-02-29 09:58:40 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-02-29 10:31:56 +0100 |
commit | 8bf0f54b4b4b50f86e8531ac8392dd31f45973ae (patch) | |
tree | 5190c8c75411e8171d346d066a06f78284ff9c20 | |
parent | 370cdc0cc062e06d6974a199189303281a4db160 (diff) | |
download | gnutls-8bf0f54b4b4b50f86e8531ac8392dd31f45973ae.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 f7d65d5b5f..8805a6a3d9 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; } |