From 9db6a27921f4e6d6e0aaefc1548610c5e820314c Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 23 Feb 2017 14:47:36 -0800 Subject: [PATCH] =?UTF-8?q?Fixes=20for=20scan-build=20warnings.=20Fix=20po?= =?UTF-8?q?ssible=20memory=20leak=20in=20wolfSSL=5FDH=5Fnew=20on=20failure?= =?UTF-8?q?.=20Add=20null=20checks=20in=20integer.c=20for=20destination=20?= =?UTF-8?q?to=20make=20sure=20=E2=80=9Cdp=E2=80=9D=20grows=20when=20NULL?= =?UTF-8?q?=20(even=20though=20never=20happens=20in=20real-use).=20Added?= =?UTF-8?q?=20suppression=20of=20wc=5Fport.c=20warning=20=E2=80=9CValue=20?= =?UTF-8?q?stored=20to=20'ret'=20is=20never=20read=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssl.c | 1 + wolfcrypt/src/integer.c | 4 ++-- wolfcrypt/src/wc_port.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 5fcd828fd..0b494ac03 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -16133,6 +16133,7 @@ WOLFSSL_DH* wolfSSL_DH_new(void) if (wc_InitDhKey(key) != 0) { WOLFSSL_MSG("wolfSSL_DH_new InitDhKey failure"); XFREE(key, NULL, DYNAMIC_TYPE_DH); + XFREE(external, NULL, DYNAMIC_TYPE_DH); return NULL; } external->internal = key; diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index efa0af912..067a55012 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -330,7 +330,7 @@ int mp_copy (mp_int * a, mp_int * b) } /* grow dest */ - if (b->alloc < a->used) { + if (b->alloc < a->used || b->dp == NULL) { if ((res = mp_grow (b, a->used)) != MP_OKAY) { return res; } @@ -1633,7 +1633,7 @@ int s_mp_sub (mp_int * a, mp_int * b, mp_int * c) max_a = a->used; /* init result */ - if (c->alloc < max_a) { + if (c->alloc < max_a || c->dp == NULL) { if ((res = mp_grow (c, max_a)) != MP_OKAY) { return res; } diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index cf82ca674..532bf107e 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -78,6 +78,7 @@ int wolfCrypt_Init(void) WOLFSSL_MSG(ippGetStatusString(ret)); WOLFSSL_MSG("Using default fast IPP library"); ret = 0; + (void)ret; /* suppress not read warning */ } #endif