We already have BIO_ADDR_dup() but in some contexts that is not sufficent.
We implement BIO_ADDR_copy() and make BIO_ADDR_dup() use it.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22164)
OPENSSL_free(ap);
}
+int BIO_ADDR_copy(BIO_ADDR *dst, const BIO_ADDR *src)
+{
+ if (dst == NULL || src == NULL)
+ return 0;
+
+ if (src->sa.sa_family == AF_UNSPEC) {
+ BIO_ADDR_clear(dst);
+ return 1;
+ }
+
+ return BIO_ADDR_make(dst, &src->sa);
+}
+
BIO_ADDR *BIO_ADDR_dup(const BIO_ADDR *ap)
{
BIO_ADDR *ret = NULL;
if (ap != NULL) {
ret = BIO_ADDR_new();
- if (ret != NULL)
- BIO_ADDR_make(ret, &ap->sa);
+ if (ret != NULL && !BIO_ADDR_copy(ret, ap)) {
+ BIO_ADDR_free(ret);
+ ret = NULL;
+ }
}
return ret;
}
# ifndef OPENSSL_NO_SOCK
BIO_ADDR *BIO_ADDR_new(void);
+int BIO_ADDR_copy(BIO_ADDR *dst, const BIO_ADDR *src);
BIO_ADDR *BIO_ADDR_dup(const BIO_ADDR *ap);
int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
const void *where, size_t wherelen, unsigned short port);
X509_STORE_CTX_set_get_crl ? 3_2_0 EXIST::FUNCTION:
X509_STORE_CTX_set_current_reasons ? 3_2_0 EXIST::FUNCTION:
OSSL_STORE_delete ? 3_2_0 EXIST::FUNCTION:
+BIO_ADDR_copy ? 3_2_0 EXIST::FUNCTION:SOCK