From 28be1d0cb3bbdab150d9fd74f880955b66589ded Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 12 Nov 2020 11:59:01 -0800 Subject: [PATCH] Scan-Build Fixes 1. Fix some potential uninitialized pointer errors in the functions sp_RsaPublic_2048, sp_RsaPublic_3072, and sp_RsaPublic_4096 for small stack builds. To recreate: $ scan-build ./configure --enable-sp=small --enable-smallstack --enable-smallstackcache CPPFLAGS="-DECC_CACHE_CURVE -DHAVE_WOLF_BIGINT" --- wolfcrypt/src/sp_c32.c | 18 +++++++++--------- wolfcrypt/src/sp_c64.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 63b472257..971ba5d0d 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -3203,9 +3203,9 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm, { #ifdef WOLFSSL_SP_SMALL sp_digit* d = NULL; - sp_digit* a; - sp_digit* m; - sp_digit* r; + sp_digit* a = NULL; + sp_digit* m = NULL; + sp_digit* r = NULL; sp_digit* norm; sp_digit e[1] = {0}; sp_digit mp; @@ -7090,9 +7090,9 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm, { #ifdef WOLFSSL_SP_SMALL sp_digit* d = NULL; - sp_digit* a; - sp_digit* m; - sp_digit* r; + sp_digit* a = NULL; + sp_digit* m = NULL; + sp_digit* r = NULL; sp_digit* norm; sp_digit e[1] = {0}; sp_digit mp; @@ -11144,9 +11144,9 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm, { #ifdef WOLFSSL_SP_SMALL sp_digit* d = NULL; - sp_digit* a; - sp_digit* m; - sp_digit* r; + sp_digit* a = NULL; + sp_digit* m = NULL; + sp_digit* r = NULL; sp_digit* norm; sp_digit e[1] = {0}; sp_digit mp; diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 297cc8b0b..ff0b50aae 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -2843,9 +2843,9 @@ int sp_RsaPublic_2048(const byte* in, word32 inLen, mp_int* em, mp_int* mm, { #ifdef WOLFSSL_SP_SMALL sp_digit* d = NULL; - sp_digit* a; - sp_digit* m; - sp_digit* r; + sp_digit* a = NULL; + sp_digit* m = NULL; + sp_digit* r = NULL; sp_digit* norm; sp_digit e[1] = {0}; sp_digit mp; @@ -7005,9 +7005,9 @@ int sp_RsaPublic_3072(const byte* in, word32 inLen, mp_int* em, mp_int* mm, { #ifdef WOLFSSL_SP_SMALL sp_digit* d = NULL; - sp_digit* a; - sp_digit* m; - sp_digit* r; + sp_digit* a = NULL; + sp_digit* m = NULL; + sp_digit* r = NULL; sp_digit* norm; sp_digit e[1] = {0}; sp_digit mp; @@ -11403,9 +11403,9 @@ int sp_RsaPublic_4096(const byte* in, word32 inLen, mp_int* em, mp_int* mm, { #ifdef WOLFSSL_SP_SMALL sp_digit* d = NULL; - sp_digit* a; - sp_digit* m; - sp_digit* r; + sp_digit* a = NULL; + sp_digit* m = NULL; + sp_digit* r = NULL; sp_digit* norm; sp_digit e[1] = {0}; sp_digit mp;