Skip to content

Commit 3c06638

Browse files
committed
wolfcrypt/src/aes.c: fixes for bugprone-macro-parentheses;
wolfcrypt/src/ecc.c: fix for nullPointerRedundantCheck ("possible null pointer dereference").
1 parent 870f7cc commit 3c06638

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,12 +1978,12 @@ static word32 GetTable8_4(const byte* t, byte o0, byte o1, byte o2, byte o3)
19781978
#define GetTable(t, o) t[o]
19791979
#define GetTable8(t, o) t[o]
19801980
#define GetTable_Multi(t, t0, o0, t1, o1, t2, o2, t3, o3) \
1981-
*t0 = t[o0]; *t1 = t[o1]; *t2 = t[o2]; *t3 = t[o3]
1981+
*(t0) = (t)[o0]; *(t1) = (t)[o1]; *(t2) = (t)[o2]; *(t3) = (t)[o3]
19821982
#define XorTable_Multi(t, t0, o0, t1, o1, t2, o2, t3, o3) \
1983-
*t0 ^= t[o0]; *t1 ^= t[o1]; *t2 ^= t[o2]; *t3 ^= t[o3]
1983+
*(t0) ^= (t)[o0]; *(t1) ^= (t)[o1]; *(t2) ^= (t)[o2]; *(t3) ^= (t)[o3]
19841984
#define GetTable8_4(t, o0, o1, o2, o3) \
1985-
(((word32)t[o0] << 24) | ((word32)t[o1] << 16) | \
1986-
((word32)t[o2] << 8) | ((word32)t[o3] << 0))
1985+
(((word32)(t)[o0] << 24) | ((word32)(t)[o1] << 16) | \
1986+
((word32)(t)[o2] << 8) | ((word32)(t)[o3] << 0))
19871987
#endif
19881988

19891989
/* Software AES - ECB Encrypt */

wolfcrypt/src/ecc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,6 +3368,10 @@ static int ecc_key_tmp_init(ecc_key* key, void* heap)
33683368

33693369
(void)heap;
33703370

3371+
if (key == NULL) {
3372+
return ECC_BAD_ARG_E;
3373+
}
3374+
33713375
XMEMSET(key, 0, sizeof(*key));
33723376

33733377
#if defined(WOLFSSL_SP_MATH_ALL) && defined(WOLFSSL_SMALL_STACK)

0 commit comments

Comments
 (0)