From dd517fd81c372198c39558064edaa5ff570d9c40 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 20 Aug 2020 15:13:43 -0700 Subject: [PATCH] Fixed several compiler warnings with inline variable declaration, deprecated func decl and small stack use of invaid memory (heap). Thanks @douzzer for these. --- wolfcrypt/src/asn.c | 14 +++++++------- wolfcrypt/src/pkcs7.c | 2 +- wolfcrypt/src/sha512.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 986a747f6..c22604d04 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -6196,15 +6196,15 @@ int GetAsnTimeString(void* currTime, byte* buf, word32 len) { struct tm* ts = NULL; struct tm* tmpTime = NULL; + byte* data_ptr = buf; + word32 data_len = 0; + int year, mon, day, hour, mini, sec; #if defined(NEED_TMP_TIME) struct tm tmpTimeStorage; tmpTime = &tmpTimeStorage; #else (void)tmpTime; #endif - byte* data_ptr = buf; - word32 data_len = 0; - int year, mon, day, hour, mini, sec; WOLFSSL_ENTER("SetAsnTimeString"); @@ -11682,7 +11682,7 @@ static int SetEd25519PublicKey(byte* output, ed25519_key* key, int with_header) idx = wc_ed25519_export_public(key, pub, &pubSz); if (idx != 0) { #ifdef WOLFSSL_SMALL_STACK - XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return idx; } @@ -11692,7 +11692,7 @@ static int SetEd25519PublicKey(byte* output, ed25519_key* key, int with_header) #ifdef WOLFSSL_SMALL_STACK algo = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (algo == NULL) { - XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; } #endif @@ -11786,7 +11786,7 @@ static int SetEd448PublicKey(byte* output, ed448_key* key, int with_header) idx = wc_ed448_export_public(key, pub, &pubSz); if (idx != 0) { #ifdef WOLFSSL_SMALL_STACK - XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return idx; } @@ -11796,7 +11796,7 @@ static int SetEd448PublicKey(byte* output, ed448_key* key, int with_header) #ifdef WOLFSSL_SMALL_STACK algo = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (algo == NULL) { - XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; } #endif diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 8e4b00583..6e6d4ec03 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -9238,6 +9238,7 @@ static int wc_PKCS7_DecryptKari(PKCS7* pkcs7, byte* in, word32 inSz, switch (pkcs7->state) { case WC_PKCS7_DECRYPT_KARI: { + WC_PKCS7_KARI* kari; #ifndef NO_PKCS7_STREAM /* @TODO for now just get full buffer, needs divided up */ if ((ret = wc_PKCS7_AddDataToStream(pkcs7, in, inSz, @@ -9254,7 +9255,6 @@ static int wc_PKCS7_DecryptKari(PKCS7* pkcs7, byte* in, word32 inSz, } pkiMsgSz = (word32)rc; #endif - WC_PKCS7_KARI* kari; kari = wc_PKCS7_KariNew(pkcs7, WC_PKCS7_DECODE); if (kari == NULL) diff --git a/wolfcrypt/src/sha512.c b/wolfcrypt/src/sha512.c index 22c471884..e8a427962 100644 --- a/wolfcrypt/src/sha512.c +++ b/wolfcrypt/src/sha512.c @@ -341,7 +341,7 @@ static int InitSha512(wc_Sha512* sha512) #define Transform_Sha512_Len(sha512, len) \ (*Transform_Sha512_Len_p)(sha512, len) - static void Sha512_SetTransform() + static void Sha512_SetTransform(void) { if (transform_check) return;