]> granicus.if.org Git - p11-kit/commitdiff
Don't print erroneous debug messages when skipping files
authorStef Walter <stefw@gnome.org>
Thu, 4 Apr 2013 06:04:10 +0000 (08:04 +0200)
committerStef Walter <stefw@gnome.org>
Thu, 4 Apr 2013 06:04:10 +0000 (08:04 +0200)
The parser automatically skips over files that it cannot parse. Don't
print confusing debug messages about DER parse failures when it does so.

common/asn1.c
trust/parser.c

index 45d91abe4bc1075dc34607f66fdc3876f8a32f74..29cca3a2459e2cd43df034a0ea345326c909efe6 100644 (file)
@@ -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;
        }
 
index b2555b1bb3061eefd040cc512e32e394b452290a..7690d6ac47d304cc5529ee96f2fcdb21a4e7541f 100644 (file)
@@ -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;