resolve windows warnings and add sanity check with PKCS12 parse

pull/769/head
Jacob Barthelmeh 2017-02-28 14:33:07 -07:00
parent b86dfd582f
commit f77458992e
4 changed files with 14 additions and 9 deletions

View File

@ -7070,7 +7070,8 @@ int do_mp_jacobi(mp_int* a, mp_int* n, int* c);
int do_mp_jacobi(mp_int* a, mp_int* n, int* c) int do_mp_jacobi(mp_int* a, mp_int* n, int* c)
{ {
int k, s, r, res; int k, s, res;
int r = 0; /* initialize to help static analysis out */
mp_digit residue; mp_digit residue;
/* if a < 0 return MP_VAL */ /* if a < 0 return MP_VAL */

View File

@ -830,15 +830,11 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
saltSz = hashSz; saltSz = hashSz;
} }
do {
ret = wc_HmacSetKey(&myHmac, type, localSalt, saltSz); ret = wc_HmacSetKey(&myHmac, type, localSalt, saltSz);
if (ret != 0) if (ret == 0)
break; ret = wc_HmacUpdate(&myHmac, inKey, inKeySz);
ret = wc_HmacUpdate(&myHmac, inKey, inKeySz); if (ret == 0)
if (ret != 0) ret = wc_HmacFinal(&myHmac, prk);
break;
ret = wc_HmacFinal(&myHmac, prk);
} while (0);
if (ret == 0) { if (ret == 0) {
while (outIdx < outSz) { while (outIdx < outSz) {

View File

@ -4223,6 +4223,10 @@ static int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
q.used = a->used; q.used = a->used;
q.sign = a->sign; q.sign = a->sign;
} }
else {
mp_init(&q); /* initialize to help static analysis */
}
w = 0; w = 0;
for (ix = a->used - 1; ix >= 0; ix--) { for (ix = a->used - 1; ix >= 0; ix--) {

View File

@ -709,6 +709,10 @@ int wc_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw,
} }
} }
if (pkcs12->safe == NULL) {
WOLFSSL_MSG("No PKCS12 safes to parse");
return BAD_FUNC_ARG;
}
/* Decode content infos */ /* Decode content infos */
ci = pkcs12->safe->CI; ci = pkcs12->safe->CI;