From: tb Date: Tue, 4 Jan 2022 20:33:02 +0000 (+0000) Subject: Only check the parent to be canonical once we know it is non-NULL. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=598f4af5e2c76af3bfaac0773866dd497b14d962;p=openbsd Only check the parent to be canonical once we know it is non-NULL. suggested by jsing during review --- diff --git a/lib/libcrypto/x509/x509_addr.c b/lib/libcrypto/x509/x509_addr.c index e80ba356610..0b735c3bc50 100644 --- a/lib/libcrypto/x509/x509_addr.c +++ b/lib/libcrypto/x509/x509_addr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_addr.c,v 1.55 2022/01/04 20:30:30 tb Exp $ */ +/* $OpenBSD: x509_addr.c,v 1.56 2022/01/04 20:33:02 tb Exp $ */ /* * Contributed to the OpenSSL Project by the American Registry for * Internet Numbers ("ARIN"). @@ -1763,12 +1763,8 @@ addr_validate_path_internal(X509_STORE_CTX *ctx, STACK_OF(X509) *chain, */ for (i++; i < sk_X509_num(chain); i++) { x = sk_X509_value(chain, i); - parent = x->rfc3779_addr; - if (!X509v3_addr_is_canonical(parent)) - validation_err(X509_V_ERR_INVALID_EXTENSION); - - if (parent == NULL) { + if ((parent = x->rfc3779_addr) == NULL) { for (j = 0; j < sk_IPAddressFamily_num(child); j++) { fc = sk_IPAddressFamily_value(child, j); @@ -1780,6 +1776,9 @@ addr_validate_path_internal(X509_STORE_CTX *ctx, STACK_OF(X509) *chain, continue; } + if (!X509v3_addr_is_canonical(parent)) + validation_err(X509_V_ERR_INVALID_EXTENSION); + sk_IPAddressFamily_set_cmp_func(parent, IPAddressFamily_cmp); /*