From: Nikos Mavrogiannopoulos Date: Mon, 29 Feb 2016 08:58:40 +0000 (+0100) Subject: cipher.c: Fixes to prevent undefined behavior (found with libubsan) X-Git-Tag: gnutls_3_5_0~289 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=60f3560ba5f2ccf3adf5ebf7e2eea9907d555cff;p=thirdparty%2Fgnutls.git cipher.c: Fixes to prevent undefined behavior (found with libubsan) --- 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; }