]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
cipher.c: Fixes to prevent undefined behavior (found with libubsan)
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 29 Feb 2016 08:58:40 +0000 (09:58 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 29 Feb 2016 08:58:40 +0000 (09:58 +0100)
lib/nettle/cipher.c

index 602f5c72b71adf0598593c7d39abb338d51da7da..bf99985338319e86eb185bf160eecebcd4fe6a0c 100644 (file)
@@ -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;
        }