]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
(_gnutls_x509_ext_extract_basicConstraints): Make sure
authorSimon Josefsson <simon@josefsson.org>
Fri, 26 Jan 2007 09:28:29 +0000 (09:28 +0000)
committerSimon Josefsson <simon@josefsson.org>
Fri, 26 Jan 2007 09:28:29 +0000 (09:28 +0000)
pathLenConstraint is read, even if CA reading fails.

lib/x509/extensions.c

index aa2a59b2cebe69f4040b2158ae567f5be5a7e853..38f46bb35d26678f6e113d4e8d0e2ae9983f4391 100644 (file)
@@ -502,8 +502,6 @@ _gnutls_x509_ext_extract_basicConstraints (int *CA,
   char str[128];
   int len, result;
 
-  *CA = 0;
-
   if ((result = asn1_create_element
        (_gnutls_get_pkix (), "PKIX1.BasicConstraints", &ext)) != ASN1_SUCCESS)
     {
@@ -512,7 +510,6 @@ _gnutls_x509_ext_extract_basicConstraints (int *CA,
     }
 
   result = asn1_der_decoding (&ext, extnValue, extnValueLen, NULL);
-
   if (result != ASN1_SUCCESS)
     {
       gnutls_assert ();
@@ -520,16 +517,6 @@ _gnutls_x509_ext_extract_basicConstraints (int *CA,
       return _gnutls_asn2err (result);
     }
 
-  len = sizeof (str) - 1;
-  /* the default value of cA is false.
-   */
-  result = asn1_read_value (ext, "cA", str, &len);
-  if (result != ASN1_SUCCESS)
-    {
-      asn1_delete_structure (&ext);
-      return 0;
-    }
-
   if (pathLenConstraint)
     {
       result = _gnutls_x509_read_uint (ext, "pathLenConstraint",
@@ -543,13 +530,17 @@ _gnutls_x509_ext_extract_basicConstraints (int *CA,
        }
     }
 
-  asn1_delete_structure (&ext);
-
-  if (strcmp (str, "TRUE") == 0)
+  /* the default value of cA is false.
+   */
+  len = sizeof (str) - 1;
+  result = asn1_read_value (ext, "cA", str, &len);
+  if (result == ASN1_SUCCESS && strcmp (str, "TRUE") == 0)
     *CA = 1;
   else
     *CA = 0;
 
+  asn1_delete_structure (&ext);
+
   return 0;
 }