-/* $OpenBSD: x509_addr.c,v 1.39 2021/12/28 19:56:45 tb Exp $ */
+/* $OpenBSD: x509_addr.c,v 1.40 2021/12/28 19:59:33 tb Exp $ */
/*
* Contributed to the OpenSSL Project by the American Registry for
* Internet Numbers ("ARIN").
X509v3_addr_add_range(IPAddrBlocks *addr, const unsigned afi,
const unsigned *safi, unsigned char *min, unsigned char *max)
{
- IPAddressOrRanges *aors = make_prefix_or_range(addr, afi, safi);
+ IPAddressOrRanges *aors;
IPAddressOrRange *aor;
- int length = length_from_afi(afi);
- if (aors == NULL)
+ int length;
+
+ if ((aors = make_prefix_or_range(addr, afi, safi)) == NULL)
return 0;
+
+ length = length_from_afi(afi);
+
if (!make_addressRange(&aor, min, max, length))
return 0;
- if (sk_IPAddressOrRange_push(aors, aor))
- return 1;
- IPAddressOrRange_free(aor);
- return 0;
+
+ if (sk_IPAddressOrRange_push(aors, aor) <= 0) {
+ IPAddressOrRange_free(aor);
+ return 0;
+ }
+
+ return 1;
}
/*