summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/asn1.c12
-rw-r--r--trust/parser.c8
2 files changed, 11 insertions, 9 deletions
diff --git a/common/asn1.c b/common/asn1.c
index 45d91ab..29cca3a 100644
--- a/common/asn1.c
+++ b/common/asn1.c
@@ -142,18 +142,18 @@ p11_asn1_decode (p11_dict *asn1_defs,
return_val_if_fail (asn1_defs != NULL, NULL);
- if (message == NULL)
- message = msg;
-
asn = p11_asn1_create (asn1_defs, struct_name);
return_val_if_fail (asn != NULL, NULL);
/* asn1_der_decoding destroys the element if fails */
- ret = asn1_der_decoding (&asn, der, der_len, message);
+ ret = asn1_der_decoding (&asn, der, der_len, message ? message : msg);
if (ret != ASN1_SUCCESS) {
- p11_debug ("couldn't parse %s: %s: %s",
- struct_name, asn1_strerror (ret), message);
+ /* If caller passed in a message buffer, assume they're logging */
+ if (!message) {
+ p11_debug ("couldn't parse %s: %s: %s",
+ struct_name, asn1_strerror (ret), msg);
+ }
return NULL;
}
diff --git a/trust/parser.c b/trust/parser.c
index b2555b1..7690d6a 100644
--- a/trust/parser.c
+++ b/trust/parser.c
@@ -264,13 +264,14 @@ parse_der_x509_certificate (p11_parser *parser,
const unsigned char *data,
size_t length)
{
+ char message[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
CK_BYTE idv[ID_LENGTH];
CK_ATTRIBUTE id = { CKA_ID, idv, sizeof (idv) };
CK_ATTRIBUTE *attrs;
CK_ATTRIBUTE *value;
node_asn *cert;
- cert = p11_asn1_decode (parser->asn1_defs, "PKIX1.Certificate", data, length, NULL);
+ cert = p11_asn1_decode (parser->asn1_defs, "PKIX1.Certificate", data, length, message);
if (cert == NULL)
return P11_PARSE_UNRECOGNIZED;
@@ -557,6 +558,7 @@ parse_openssl_trusted_certificate (p11_parser *parser,
const unsigned char *data,
size_t length)
{
+ char message[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
CK_ATTRIBUTE *attrs;
CK_BYTE idv[ID_LENGTH];
CK_ATTRIBUTE id = { CKA_ID, idv, sizeof (idv) };
@@ -579,11 +581,11 @@ parse_openssl_trusted_certificate (p11_parser *parser,
if (cert_len <= 0)
return P11_PARSE_UNRECOGNIZED;
- cert = p11_asn1_decode (parser->asn1_defs, "PKIX1.Certificate", data, cert_len, NULL);
+ cert = p11_asn1_decode (parser->asn1_defs, "PKIX1.Certificate", data, cert_len, message);
if (cert == NULL)
return P11_PARSE_UNRECOGNIZED;
- aux = p11_asn1_decode (parser->asn1_defs, "OPENSSL.CertAux", data + cert_len, length - cert_len, NULL);
+ aux = p11_asn1_decode (parser->asn1_defs, "OPENSSL.CertAux", data + cert_len, length - cert_len, message);
if (aux == NULL) {
asn1_delete_structure (&cert);
return P11_PARSE_UNRECOGNIZED;