Merge pull request #2748 from tmael/fix_cppcheck

Fix cppcheck
This commit is contained in:
JacobBarthelmeh
2020-02-05 16:02:22 -07:00
committed by GitHub
7 changed files with 53 additions and 41 deletions

View File

@@ -142,20 +142,20 @@ void HardFault_HandlerC( uint32_t *hardfault_args )
_BFAR = (*((volatile uint32_t *)(0xE000ED38))); _BFAR = (*((volatile uint32_t *)(0xE000ED38)));
printf ("\n\nHard fault handler (all numbers in hex):\n"); printf ("\n\nHard fault handler (all numbers in hex):\n");
printf ("R0 = %lx\n", (unsigned long)stacked_r0); printf ("R0 = %ux\n", stacked_r0);
printf ("R1 = %lx\n", (unsigned long)stacked_r1); printf ("R1 = %ux\n", stacked_r1);
printf ("R2 = %lx\n", (unsigned long)stacked_r2); printf ("R2 = %ux\n", stacked_r2);
printf ("R3 = %lx\n", (unsigned long)stacked_r3); printf ("R3 = %ux\n", stacked_r3);
printf ("R12 = %lx\n", (unsigned long)stacked_r12); printf ("R12 = %ux\n", stacked_r12);
printf ("LR [R14] = %lx subroutine call return address\n", (unsigned long)stacked_lr); printf ("LR [R14] = %ux subroutine call return address\n", stacked_lr);
printf ("PC [R15] = %lx program counter\n", (unsigned long)stacked_pc); printf ("PC [R15] = %ux program counter\n", stacked_pc);
printf ("PSR = %lx\n", (unsigned long)stacked_psr); printf ("PSR = %ux\n", stacked_psr);
printf ("CFSR = %lx\n", (unsigned long)_CFSR); printf ("CFSR = %ux\n", _CFSR);
printf ("HFSR = %lx\n", (unsigned long)_HFSR); printf ("HFSR = %ux\n", _HFSR);
printf ("DFSR = %lx\n", (unsigned long)_DFSR); printf ("DFSR = %ux\n", _DFSR);
printf ("AFSR = %lx\n", (unsigned long)_AFSR); printf ("AFSR = %ux\n", _AFSR);
printf ("MMAR = %lx\n", (unsigned long)_MMAR); printf ("MMAR = %ux\n", _MMAR);
printf ("BFAR = %lx\n", (unsigned long)_BFAR); printf ("BFAR = %ux\n", _BFAR);
// Break into the debugger // Break into the debugger
__asm("BKPT #0\n"); __asm("BKPT #0\n");

View File

@@ -19379,7 +19379,8 @@ void wolfSSL_ACCESS_DESCRIPTION_free(WOLFSSL_ACCESS_DESCRIPTION* access)
wolfSSL_ASN1_OBJECT_free(access->method); wolfSSL_ASN1_OBJECT_free(access->method);
if (access->location) if (access->location)
wolfSSL_GENERAL_NAME_free(access->location); wolfSSL_GENERAL_NAME_free(access->location);
access = NULL;
/* access = NULL, don't try to access or double free it */
} }
#endif #endif
@@ -30144,6 +30145,8 @@ void wolfSSL_DSA_free(WOLFSSL_DSA* dsa)
InitwolfSSL_DSA(dsa); /* set back to NULLs for safety */ InitwolfSSL_DSA(dsa); /* set back to NULLs for safety */
XFREE(dsa, NULL, DYNAMIC_TYPE_DSA); XFREE(dsa, NULL, DYNAMIC_TYPE_DSA);
/* dsa = NULL, don't try to access or double free it */
} }
} }
@@ -33324,6 +33327,7 @@ void wolfSSL_EC_KEY_free(WOLFSSL_EC_KEY *key)
InitwolfSSL_ECKey(key); /* set back to NULLs for safety */ InitwolfSSL_ECKey(key); /* set back to NULLs for safety */
XFREE(key, NULL, DYNAMIC_TYPE_ECC); XFREE(key, NULL, DYNAMIC_TYPE_ECC);
/* key = NULL, don't try to access or double free it */
} }
} }
#endif /* HAVE_ECC && (OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL) */ #endif /* HAVE_ECC && (OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL) */
@@ -33608,6 +33612,7 @@ void wolfSSL_EC_GROUP_free(WOLFSSL_EC_GROUP *group)
WOLFSSL_ENTER("wolfSSL_EC_GROUP_free"); WOLFSSL_ENTER("wolfSSL_EC_GROUP_free");
XFREE(group, NULL, DYNAMIC_TYPE_ECC); XFREE(group, NULL, DYNAMIC_TYPE_ECC);
/* group = NULL, don't try to access or double free it */
} }
#endif #endif
@@ -34124,6 +34129,7 @@ void wolfSSL_EC_POINT_free(WOLFSSL_EC_POINT *p)
p->inSet = p->exSet = 0; p->inSet = p->exSet = 0;
XFREE(p, NULL, DYNAMIC_TYPE_ECC); XFREE(p, NULL, DYNAMIC_TYPE_ECC);
/* p = NULL, don't try to access or double free it */
} }
} }
#endif #endif
@@ -47190,6 +47196,7 @@ void wolfSSL_BN_free(WOLFSSL_BIGNUM* bn)
bn->internal = NULL; bn->internal = NULL;
} }
XFREE(bn, NULL, DYNAMIC_TYPE_BIGINT); XFREE(bn, NULL, DYNAMIC_TYPE_BIGINT);
/* bn = NULL, don't try to access or double free it */
} }
} }
@@ -47263,6 +47270,8 @@ void wolfSSL_RSA_free(WOLFSSL_RSA* rsa)
InitwolfSSL_Rsa(rsa); /* set back to NULLs for safety */ InitwolfSSL_Rsa(rsa); /* set back to NULLs for safety */
XFREE(rsa, NULL, DYNAMIC_TYPE_RSA); XFREE(rsa, NULL, DYNAMIC_TYPE_RSA);
/* rsa = NULL, don't try to access or double free it */
} }
} }

View File

@@ -5574,6 +5574,8 @@ int TLSX_UseQSHScheme(TLSX** extensions, word16 name, byte* pKey, word16 pkeySz,
if (extensions == NULL || (pKey == NULL && pkeySz != 0)) if (extensions == NULL || (pKey == NULL && pkeySz != 0))
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
extension = TLSX_Find(*extensions, TLSX_QUANTUM_SAFE_HYBRID);
/* if scheme is implemented than add */ /* if scheme is implemented than add */
if (TLSX_HaveQSHScheme(name)) { if (TLSX_HaveQSHScheme(name)) {
if ((ret = TLSX_QSH_Append(&format, name, pKey, pkeySz)) != 0) if ((ret = TLSX_QSH_Append(&format, name, pKey, pkeySz)) != 0)

View File

@@ -2258,7 +2258,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args)
#ifdef WOLFSSL_SESSION_EXPORT #ifdef WOLFSSL_SESSION_EXPORT
/* only add in more complex nonblocking case with session export tests */ /* only add in more complex nonblocking case with session export tests */
if (((func_args*)args)->argc > 0) { if (args && ((func_args*)args)->argc > 0) {
/* set as nonblock and time out for waiting on read/write */ /* set as nonblock and time out for waiting on read/write */
tcp_set_nonblocking(&clientfd); tcp_set_nonblocking(&clientfd);
wolfSSL_dtls_set_using_nonblock(ssl, 1); wolfSSL_dtls_set_using_nonblock(ssl, 1);

View File

@@ -10041,6 +10041,7 @@ int wc_EncryptedInfoParse(EncryptedInfo* info, char** pBuffer, size_t bufSz)
newline = SkipEndOfLineChars(newline, bufferEnd); newline = SkipEndOfLineChars(newline, bufferEnd);
/* return new headerEnd */ /* return new headerEnd */
*pBuffer = newline; *pBuffer = newline;
} }

View File

@@ -134,16 +134,16 @@ int curve25519(byte* q, byte* n, byte* p)
#if 0 #if 0
unsigned char e[32]; unsigned char e[32];
#endif #endif
fe x1; fe x1 = {0};
fe x2; fe x2 = {0};
fe z2; fe z2 = {0};
fe x3; fe x3 = {0};
fe z3; fe z3 = {0};
fe tmp0; fe tmp0 = {0};
fe tmp1; fe tmp1 = {0};
int pos; int pos = 0;
unsigned int swap; unsigned int swap = 0;
unsigned int b; unsigned int b = 0;
/* Clamp already done during key generation and import */ /* Clamp already done during key generation and import */
#if 0 #if 0
@@ -645,11 +645,11 @@ void fe_frombytes(fe h,const unsigned char *s)
void fe_invert(fe out,const fe z) void fe_invert(fe out,const fe z)
{ {
fe t0; fe t0 = {0};
fe t1; fe t1 = {0};
fe t2; fe t2 = {0};
fe t3; fe t3 = {0};
int i; int i = 0;
/* pow225521 */ /* pow225521 */
fe_sq(t0,z); for (i = 1;i < 1;++i) fe_sq(t0,t0); fe_sq(t0,z); for (i = 1;i < 1;++i) fe_sq(t0,t0);
@@ -1263,10 +1263,10 @@ void fe_sq2(fe h,const fe f)
void fe_pow22523(fe out,const fe z) void fe_pow22523(fe out,const fe z)
{ {
fe t0; fe t0 = {0};
fe t1; fe t1 = {0};
fe t2; fe t2 = {0};
int i; int i = 0;
fe_sq(t0,z); for (i = 1;i < 1;++i) fe_sq(t0,t0); fe_sq(t0,z); for (i = 1;i < 1;++i) fe_sq(t0,t0);
fe_sq(t1,t0); for (i = 1;i < 2;++i) fe_sq(t1,t1); fe_sq(t1,t0); for (i = 1;i < 2;++i) fe_sq(t1,t1);