Merge pull request #2470 from SparkiDev/build-fixes

Fixes from overnight build failures
This commit is contained in:
toddouska
2019-09-19 13:38:25 -07:00
committed by GitHub
4 changed files with 16 additions and 23 deletions

View File

@ -21277,22 +21277,22 @@ WOLFSSL_X509_STORE* wolfSSL_X509_STORE_new(void)
{ {
WOLFSSL_X509_STORE* store = NULL; WOLFSSL_X509_STORE* store = NULL;
if((store = (WOLFSSL_X509_STORE*)XMALLOC(sizeof(WOLFSSL_X509_STORE), NULL, if ((store = (WOLFSSL_X509_STORE*)XMALLOC(sizeof(WOLFSSL_X509_STORE), NULL,
DYNAMIC_TYPE_X509_STORE)) == NULL) DYNAMIC_TYPE_X509_STORE)) == NULL)
goto err_exit; goto err_exit;
XMEMSET(store, 0, sizeof(WOLFSSL_X509_STORE)); XMEMSET(store, 0, sizeof(WOLFSSL_X509_STORE));
store->isDynamic = 1; store->isDynamic = 1;
if((store->cm = wolfSSL_CertManagerNew()) == NULL) if ((store->cm = wolfSSL_CertManagerNew()) == NULL)
goto err_exit; goto err_exit;
#ifdef HAVE_CRL #ifdef HAVE_CRL
store->crl = NULL; store->crl = NULL;
if((store->crl = (WOLFSSL_X509_CRL *)XMALLOC(sizeof(WOLFSSL_X509_CRL), if ((store->crl = (WOLFSSL_X509_CRL *)XMALLOC(sizeof(WOLFSSL_X509_CRL),
NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL) NULL, DYNAMIC_TYPE_TMP_BUFFER)) == NULL)
goto err_exit; goto err_exit;
if(InitCRL(store->crl, NULL) < 0) if (InitCRL(store->crl, NULL) < 0)
goto err_exit; goto err_exit;
#endif #endif
@ -21307,19 +21307,9 @@ WOLFSSL_X509_STORE* wolfSSL_X509_STORE_new(void)
return store; return store;
err_exit: err_exit:
if(store == NULL) if (store == NULL)
return NULL; return NULL;
if(store->cm != NULL)
wolfSSL_CertManagerFree(store->cm);
#ifdef HAVE_CRL
if(store->crl != NULL)
wolfSSL_X509_CRL_free(store->crl);
#endif
#ifdef OPENSSL_EXTRA
if (store->param != NULL){
XFREE(store->param,NULL,DYNAMIC_TYPE_OPENSSL);
}
#endif
wolfSSL_X509_STORE_free(store); wolfSSL_X509_STORE_free(store);
return NULL; return NULL;
@ -21336,9 +21326,8 @@ void wolfSSL_X509_STORE_free(WOLFSSL_X509_STORE* store)
wolfSSL_X509_CRL_free(store->crl); wolfSSL_X509_CRL_free(store->crl);
#endif #endif
#ifdef OPENSSL_EXTRA #ifdef OPENSSL_EXTRA
if (store->param != NULL){ if (store->param != NULL)
XFREE(store->param,NULL,DYNAMIC_TYPE_OPENSSL); XFREE(store->param, NULL, DYNAMIC_TYPE_OPENSSL);
}
#endif #endif
XFREE(store, NULL, DYNAMIC_TYPE_X509_STORE); XFREE(store, NULL, DYNAMIC_TYPE_X509_STORE);
} }

View File

@ -2831,7 +2831,7 @@ int mp_set_bit (mp_int * a, int b)
{ {
int i = b / DIGIT_BIT, res; int i = b / DIGIT_BIT, res;
if (a->used < (int)(i + 1)) { if (a->dp == NULL || a->used < (int)(i + 1)) {
/* grow a to accommodate the single bit */ /* grow a to accommodate the single bit */
if ((res = mp_grow (a, i + 1)) != MP_OKAY) { if ((res = mp_grow (a, i + 1)) != MP_OKAY) {
return res; return res;

View File

@ -1113,6 +1113,8 @@ int wc_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw,
ERROR_OUT(ASN_PARSE_E, exit_pk12par); ERROR_OUT(ASN_PARSE_E, exit_pk12par);
} }
if ((ret = GetLength(data, &idx, &size, ci->dataSz)) <= 0) { if ((ret = GetLength(data, &idx, &size, ci->dataSz)) <= 0) {
if (ret == 0)
ret = ASN_PARSE_E;
goto exit_pk12par; goto exit_pk12par;
} }
if (*pkey == NULL) { if (*pkey == NULL) {
@ -1239,6 +1241,8 @@ int wc_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw,
} }
if ((ret = GetLength(data, &idx, &size, ci->dataSz)) if ((ret = GetLength(data, &idx, &size, ci->dataSz))
<= 0) { <= 0) {
if (ret == 0)
ret = ASN_PARSE_E;
goto exit_pk12par; goto exit_pk12par;
} }
if (GetASNTag(data, &idx, &tag, ci->dataSz) < 0) { if (GetASNTag(data, &idx, &tag, ci->dataSz) < 0) {

View File

@ -1513,7 +1513,7 @@ static int FlattenAttributes(PKCS7* pkcs7, byte* output, EncodedAttrib* ea,
if (derArr == NULL) { if (derArr == NULL) {
return MEMORY_E; return MEMORY_E;
} }
ForceZero(derArr, eaSz); ForceZero(derArr, eaSz * sizeof(FlatAttrib*));
for (i = 0; i < eaSz; i++) { for (i = 0; i < eaSz; i++) {
derArr[i] = (FlatAttrib*) XMALLOC(sizeof(FlatAttrib), pkcs7->heap, derArr[i] = (FlatAttrib*) XMALLOC(sizeof(FlatAttrib), pkcs7->heap,