fix missing XMALLOC/FREE types

This commit is contained in:
toddouska
2015-11-19 10:20:28 -08:00
parent 4da70f9fe9
commit 2698736aaf
4 changed files with 32 additions and 22 deletions

View File

@@ -1567,8 +1567,8 @@ void FreeX509(WOLFSSL_X509* x509)
XFREE(x509->derCert.buffer, NULL, DYNAMIC_TYPE_SUBJECT_CN); XFREE(x509->derCert.buffer, NULL, DYNAMIC_TYPE_SUBJECT_CN);
XFREE(x509->sig.buffer, NULL, DYNAMIC_TYPE_SIGNATURE); XFREE(x509->sig.buffer, NULL, DYNAMIC_TYPE_SIGNATURE);
#ifdef OPENSSL_EXTRA #ifdef OPENSSL_EXTRA
XFREE(x509->authKeyId, NULL, 0); XFREE(x509->authKeyId, NULL, DYNAMIC_TYPE_X509_EXT);
XFREE(x509->subjKeyId, NULL, 0); XFREE(x509->subjKeyId, NULL, DYNAMIC_TYPE_X509_EXT);
#endif /* OPENSSL_EXTRA */ #endif /* OPENSSL_EXTRA */
if (x509->altNames) if (x509->altNames)
FreeAltNames(x509->altNames, NULL); FreeAltNames(x509->altNames, NULL);
@@ -4195,7 +4195,8 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert)
x509->authKeyIdSet = dCert->extAuthKeyIdSet; x509->authKeyIdSet = dCert->extAuthKeyIdSet;
x509->authKeyIdCrit = dCert->extAuthKeyIdCrit; x509->authKeyIdCrit = dCert->extAuthKeyIdCrit;
if (dCert->extAuthKeyIdSrc != NULL && dCert->extAuthKeyIdSz != 0) { if (dCert->extAuthKeyIdSrc != NULL && dCert->extAuthKeyIdSz != 0) {
x509->authKeyId = (byte*)XMALLOC(dCert->extAuthKeyIdSz, NULL, 0); x509->authKeyId = (byte*)XMALLOC(dCert->extAuthKeyIdSz, NULL,
DYNAMIC_TYPE_X509_EXT);
if (x509->authKeyId != NULL) { if (x509->authKeyId != NULL) {
XMEMCPY(x509->authKeyId, XMEMCPY(x509->authKeyId,
dCert->extAuthKeyIdSrc, dCert->extAuthKeyIdSz); dCert->extAuthKeyIdSrc, dCert->extAuthKeyIdSz);
@@ -4207,7 +4208,8 @@ int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert)
x509->subjKeyIdSet = dCert->extSubjKeyIdSet; x509->subjKeyIdSet = dCert->extSubjKeyIdSet;
x509->subjKeyIdCrit = dCert->extSubjKeyIdCrit; x509->subjKeyIdCrit = dCert->extSubjKeyIdCrit;
if (dCert->extSubjKeyIdSrc != NULL && dCert->extSubjKeyIdSz != 0) { if (dCert->extSubjKeyIdSrc != NULL && dCert->extSubjKeyIdSz != 0) {
x509->subjKeyId = (byte*)XMALLOC(dCert->extSubjKeyIdSz, NULL, 0); x509->subjKeyId = (byte*)XMALLOC(dCert->extSubjKeyIdSz, NULL,
DYNAMIC_TYPE_X509_EXT);
if (x509->subjKeyId != NULL) { if (x509->subjKeyId != NULL) {
XMEMCPY(x509->subjKeyId, XMEMCPY(x509->subjKeyId,
dCert->extSubjKeyIdSrc, dCert->extSubjKeyIdSz); dCert->extSubjKeyIdSrc, dCert->extSubjKeyIdSz);

View File

@@ -3514,10 +3514,10 @@ int wolfSSL_CertManagerSetOCSPOverrideURL(WOLFSSL_CERT_MANAGER* cm,
if (cm == NULL) if (cm == NULL)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
XFREE(cm->ocspOverrideURL, cm->heap, 0); XFREE(cm->ocspOverrideURL, cm->heap, DYNAMIC_TYPE_URL);
if (url != NULL) { if (url != NULL) {
int urlSz = (int)XSTRLEN(url) + 1; int urlSz = (int)XSTRLEN(url) + 1;
cm->ocspOverrideURL = (char*)XMALLOC(urlSz, cm->heap, 0); cm->ocspOverrideURL = (char*)XMALLOC(urlSz, cm->heap, DYNAMIC_TYPE_URL);
if (cm->ocspOverrideURL != NULL) { if (cm->ocspOverrideURL != NULL) {
XMEMCPY(cm->ocspOverrideURL, url, urlSz); XMEMCPY(cm->ocspOverrideURL, url, urlSz);
} }
@@ -10687,11 +10687,12 @@ WOLFSSL_X509_STORE* wolfSSL_X509_STORE_new(void)
{ {
WOLFSSL_X509_STORE* store = NULL; WOLFSSL_X509_STORE* store = NULL;
store = (WOLFSSL_X509_STORE*)XMALLOC(sizeof(WOLFSSL_X509_STORE), NULL, 0); store = (WOLFSSL_X509_STORE*)XMALLOC(sizeof(WOLFSSL_X509_STORE), NULL,
DYNAMIC_TYPE_X509_STORE);
if (store != NULL) { if (store != NULL) {
store->cm = wolfSSL_CertManagerNew(); store->cm = wolfSSL_CertManagerNew();
if (store->cm == NULL) { if (store->cm == NULL) {
XFREE(store, NULL, 0); XFREE(store, NULL, DYNAMIC_TYPE_X509_STORE);
store = NULL; store = NULL;
} }
} }
@@ -10705,7 +10706,7 @@ void wolfSSL_X509_STORE_free(WOLFSSL_X509_STORE* store)
if (store != NULL) { if (store != NULL) {
if (store->cm != NULL) if (store->cm != NULL)
wolfSSL_CertManagerFree(store->cm); wolfSSL_CertManagerFree(store->cm);
XFREE(store, NULL, 0); XFREE(store, NULL, DYNAMIC_TYPE_X509_STORE);
} }
} }
@@ -10731,8 +10732,8 @@ int wolfSSL_X509_STORE_get_by_subject(WOLFSSL_X509_STORE_CTX* ctx, int idx,
WOLFSSL_X509_STORE_CTX* wolfSSL_X509_STORE_CTX_new(void) WOLFSSL_X509_STORE_CTX* wolfSSL_X509_STORE_CTX_new(void)
{ {
WOLFSSL_X509_STORE_CTX* ctx = (WOLFSSL_X509_STORE_CTX*)XMALLOC( WOLFSSL_X509_STORE_CTX* ctx = (WOLFSSL_X509_STORE_CTX*)XMALLOC(
sizeof(WOLFSSL_X509_STORE_CTX), NULL, 0); sizeof(WOLFSSL_X509_STORE_CTX), NULL,
DYNAMIC_TYPE_X509_CTX);
if (ctx != NULL) if (ctx != NULL)
wolfSSL_X509_STORE_CTX_init(ctx, NULL, NULL, NULL); wolfSSL_X509_STORE_CTX_init(ctx, NULL, NULL, NULL);
@@ -10767,7 +10768,7 @@ void wolfSSL_X509_STORE_CTX_free(WOLFSSL_X509_STORE_CTX* ctx)
wolfSSL_X509_STORE_free(ctx->store); wolfSSL_X509_STORE_free(ctx->store);
if (ctx->current_cert != NULL) if (ctx->current_cert != NULL)
wolfSSL_FreeX509(ctx->current_cert); wolfSSL_FreeX509(ctx->current_cert);
XFREE(ctx, NULL, 0); XFREE(ctx, NULL, DYNAMIC_TYPE_X509_CTX);
} }
} }
@@ -10858,8 +10859,8 @@ void wolfSSL_EVP_PKEY_free(WOLFSSL_EVP_PKEY* key)
{ {
if (key != NULL) { if (key != NULL) {
if (key->pkey.ptr != NULL) if (key->pkey.ptr != NULL)
XFREE(key->pkey.ptr, NULL, 0); XFREE(key->pkey.ptr, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
XFREE(key, NULL, 0); XFREE(key, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
} }
} }
@@ -13768,7 +13769,7 @@ void wolfSSL_OPENSSL_free(void* p)
{ {
WOLFSSL_MSG("wolfSSL_OPENSSL_free"); WOLFSSL_MSG("wolfSSL_OPENSSL_free");
XFREE(p, NULL, 0); XFREE(p, NULL, DYNAMIC_TYPE_OPENSSL);
} }
#if defined(WOLFSSL_KEY_GEN) #if defined(WOLFSSL_KEY_GEN)

View File

@@ -1760,9 +1760,9 @@ void FreeDecodedCert(DecodedCert* cert)
FreeNameSubtrees(cert->excludedNames, cert->heap); FreeNameSubtrees(cert->excludedNames, cert->heap);
#endif /* IGNORE_NAME_CONSTRAINTS */ #endif /* IGNORE_NAME_CONSTRAINTS */
#ifdef WOLFSSL_SEP #ifdef WOLFSSL_SEP
XFREE(cert->deviceType, cert->heap, 0); XFREE(cert->deviceType, cert->heap, DYNAMIC_TYPE_X509_EXT);
XFREE(cert->hwType, cert->heap, 0); XFREE(cert->hwType, cert->heap, DYNAMIC_TYPE_X509_EXT);
XFREE(cert->hwSerialNum, cert->heap, 0); XFREE(cert->hwSerialNum, cert->heap, DYNAMIC_TYPE_X509_EXT);
#endif /* WOLFSSL_SEP */ #endif /* WOLFSSL_SEP */
#ifdef OPENSSL_EXTRA #ifdef OPENSSL_EXTRA
if (cert->issuerName.fullName != NULL) if (cert->issuerName.fullName != NULL)
@@ -3756,7 +3756,8 @@ static int DecodeAltNames(byte* input, int sz, DecodedCert* cert)
return ASN_PARSE_E; return ASN_PARSE_E;
} }
cert->hwType = (byte*)XMALLOC(strLen, cert->heap, 0); cert->hwType = (byte*)XMALLOC(strLen, cert->heap,
DYNAMIC_TYPE_X509_EXT);
if (cert->hwType == NULL) { if (cert->hwType == NULL) {
WOLFSSL_MSG("\tOut of Memory"); WOLFSSL_MSG("\tOut of Memory");
return MEMORY_E; return MEMORY_E;
@@ -3776,7 +3777,8 @@ static int DecodeAltNames(byte* input, int sz, DecodedCert* cert)
return ASN_PARSE_E; return ASN_PARSE_E;
} }
cert->hwSerialNum = (byte*)XMALLOC(strLen + 1, cert->heap, 0); cert->hwSerialNum = (byte*)XMALLOC(strLen + 1, cert->heap,
DYNAMIC_TYPE_X509_EXT);
if (cert->hwSerialNum == NULL) { if (cert->hwSerialNum == NULL) {
WOLFSSL_MSG("\tOut of Memory"); WOLFSSL_MSG("\tOut of Memory");
return MEMORY_E; return MEMORY_E;
@@ -4359,7 +4361,8 @@ static int DecodePolicyOID(char *out, word32 outSz, byte *in, word32 inSz)
if (length > 0) { if (length > 0) {
#if defined(WOLFSSL_SEP) #if defined(WOLFSSL_SEP)
cert->deviceType = (byte*)XMALLOC(length, cert->heap, 0); cert->deviceType = (byte*)XMALLOC(length, cert->heap,
DYNAMIC_TYPE_X509_EXT);
if (cert->deviceType == NULL) { if (cert->deviceType == NULL) {
WOLFSSL_MSG("\tCouldn't alloc memory for deviceType"); WOLFSSL_MSG("\tCouldn't alloc memory for deviceType");
return MEMORY_E; return MEMORY_E;

View File

@@ -288,7 +288,11 @@
DYNAMIC_TYPE_SRP = 47, DYNAMIC_TYPE_SRP = 47,
DYNAMIC_TYPE_COOKIE_PWD = 48, DYNAMIC_TYPE_COOKIE_PWD = 48,
DYNAMIC_TYPE_USER_CRYPTO = 49, DYNAMIC_TYPE_USER_CRYPTO = 49,
DYNAMIC_TYPE_OCSP_REQUEST = 50 DYNAMIC_TYPE_OCSP_REQUEST = 50,
DYNAMIC_TYPE_X509_EXT = 51,
DYNAMIC_TYPE_X509_STORE = 52,
DYNAMIC_TYPE_X509_CTX = 53,
DYNAMIC_TYPE_URL = 54
}; };
/* max error buffer string size */ /* max error buffer string size */