From: tb Date: Tue, 28 Dec 2021 19:56:45 +0000 (+0000) Subject: Style improvements in X509v3_addr_add_prefix() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6e49db69f6ae5a05edc5ba1d598c4aa54ccc303e;p=openbsd Style improvements in X509v3_addr_add_prefix() ok jsing --- diff --git a/lib/libcrypto/x509/x509_addr.c b/lib/libcrypto/x509/x509_addr.c index 0f1a9a118fb..571ca728d4a 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.38 2021/12/28 17:45:41 tb Exp $ */ +/* $OpenBSD: x509_addr.c,v 1.39 2021/12/28 19:56:45 tb Exp $ */ /* * Contributed to the OpenSSL Project by the American Registry for * Internet Numbers ("ARIN"). @@ -956,14 +956,23 @@ int X509v3_addr_add_prefix(IPAddrBlocks *addr, const unsigned afi, const unsigned *safi, unsigned char *a, const int prefixlen) { - IPAddressOrRanges *aors = make_prefix_or_range(addr, afi, safi); + IPAddressOrRanges *aors; IPAddressOrRange *aor; - if (aors == NULL || !make_addressPrefix(&aor, a, prefixlen)) + + /* XXX - check prefixlen */ + + if ((aors = make_prefix_or_range(addr, afi, safi)) == NULL) return 0; - if (sk_IPAddressOrRange_push(aors, aor)) - return 1; - IPAddressOrRange_free(aor); - return 0; + + if (!make_addressPrefix(&aor, a, prefixlen)) + return 0; + + if (sk_IPAddressOrRange_push(aors, aor) <= 0) { + IPAddressOrRange_free(aor); + return 0; + } + + return 1; } /*