Try to not leak memory.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18780 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -367,12 +367,15 @@ hx509_cms_unenvelope(hx509_context context,
|
|||||||
|
|
||||||
if (params) {
|
if (params) {
|
||||||
ret = hx509_crypto_set_params(context, crypto, params, &ivec);
|
ret = hx509_crypto_set_params(context, crypto, params, &ivec);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
hx509_crypto_destroy(crypto);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = hx509_crypto_set_key_data(crypto, key.data, key.length);
|
ret = hx509_crypto_set_key_data(crypto, key.data, key.length);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
hx509_crypto_destroy(crypto);
|
||||||
hx509_set_error_string(context, 0, ret,
|
hx509_set_error_string(context, 0, ret,
|
||||||
"Failed to set key for decryption "
|
"Failed to set key for decryption "
|
||||||
"of EnvelopedData");
|
"of EnvelopedData");
|
||||||
@@ -384,6 +387,7 @@ hx509_cms_unenvelope(hx509_context context,
|
|||||||
enccontent->length,
|
enccontent->length,
|
||||||
ivec.length ? &ivec : NULL,
|
ivec.length ? &ivec : NULL,
|
||||||
content);
|
content);
|
||||||
|
hx509_crypto_destroy(crypto);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
hx509_set_error_string(context, 0, ret,
|
hx509_set_error_string(context, 0, ret,
|
||||||
"Failed to decrypt EnvelopedData");
|
"Failed to decrypt EnvelopedData");
|
||||||
@@ -393,6 +397,7 @@ hx509_cms_unenvelope(hx509_context context,
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
|
free_EnvelopedData(&ed);
|
||||||
der_free_octet_string(&key);
|
der_free_octet_string(&key);
|
||||||
if (ivec.length)
|
if (ivec.length)
|
||||||
der_free_octet_string(&ivec);
|
der_free_octet_string(&ivec);
|
||||||
@@ -416,7 +421,7 @@ hx509_cms_envelope_1(hx509_context context,
|
|||||||
KeyTransRecipientInfo *ri;
|
KeyTransRecipientInfo *ri;
|
||||||
heim_octet_string ivec;
|
heim_octet_string ivec;
|
||||||
heim_octet_string key;
|
heim_octet_string key;
|
||||||
hx509_crypto crypto;
|
hx509_crypto crypto = NULL;
|
||||||
EnvelopedData ed;
|
EnvelopedData ed;
|
||||||
size_t size;
|
size_t size;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -441,7 +446,6 @@ hx509_cms_envelope_1(hx509_context context,
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
hx509_set_error_string(context, 0, ret,
|
hx509_set_error_string(context, 0, ret,
|
||||||
"Create random key for EnvelopedData content");
|
"Create random key for EnvelopedData content");
|
||||||
hx509_crypto_destroy(crypto);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,7 +457,6 @@ hx509_cms_envelope_1(hx509_context context,
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
hx509_set_error_string(context, 0, ret,
|
hx509_set_error_string(context, 0, ret,
|
||||||
"Failed to encrypt EnvelopedData content");
|
"Failed to encrypt EnvelopedData content");
|
||||||
hx509_crypto_destroy(crypto);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,7 +468,6 @@ hx509_cms_envelope_1(hx509_context context,
|
|||||||
hx509_set_error_string(context, 0, ret,
|
hx509_set_error_string(context, 0, ret,
|
||||||
"Failed to set crypto oid "
|
"Failed to set crypto oid "
|
||||||
"for EnvelopedData");
|
"for EnvelopedData");
|
||||||
hx509_crypto_destroy(crypto);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
ALLOC(enc_alg->parameters, 1);
|
ALLOC(enc_alg->parameters, 1);
|
||||||
@@ -474,7 +476,6 @@ hx509_cms_envelope_1(hx509_context context,
|
|||||||
hx509_set_error_string(context, 0, ret,
|
hx509_set_error_string(context, 0, ret,
|
||||||
"Failed to allocate crypto paramaters "
|
"Failed to allocate crypto paramaters "
|
||||||
"for EnvelopedData");
|
"for EnvelopedData");
|
||||||
hx509_crypto_destroy(crypto);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +483,6 @@ hx509_cms_envelope_1(hx509_context context,
|
|||||||
crypto,
|
crypto,
|
||||||
&ivec,
|
&ivec,
|
||||||
enc_alg->parameters);
|
enc_alg->parameters);
|
||||||
hx509_crypto_destroy(crypto);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -546,9 +546,10 @@ hx509_cms_envelope_1(hx509_context context,
|
|||||||
_hx509_abort("internal ASN.1 encoder error");
|
_hx509_abort("internal ASN.1 encoder error");
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (ret) {
|
if (crypto)
|
||||||
|
hx509_crypto_destroy(crypto);
|
||||||
|
if (ret)
|
||||||
der_free_octet_string(content);
|
der_free_octet_string(content);
|
||||||
}
|
|
||||||
der_free_octet_string(&key);
|
der_free_octet_string(&key);
|
||||||
der_free_octet_string(&ivec);
|
der_free_octet_string(&ivec);
|
||||||
free_EnvelopedData(&ed);
|
free_EnvelopedData(&ed);
|
||||||
|
@@ -236,6 +236,7 @@ cms_create_sd(struct cms_create_sd_options *opt, int argc, char **argv)
|
|||||||
hx509_certs_free(&anchors);
|
hx509_certs_free(&anchors);
|
||||||
hx509_certs_free(&pool);
|
hx509_certs_free(&pool);
|
||||||
hx509_certs_free(&store);
|
hx509_certs_free(&store);
|
||||||
|
hx509_cert_free(cert);
|
||||||
_hx509_unmap_file(p, sz);
|
_hx509_unmap_file(p, sz);
|
||||||
hx509_lock_free(lock);
|
hx509_lock_free(lock);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user