mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-05 13:44:41 +02:00
Merge pull request #8815 from kareem-wolfssl/zd19929
Fix wolfSSL_BIO_new_connect's handling of IPV6 addresses.
This commit is contained in:
17
src/bio.c
17
src/bio.c
@@ -2392,13 +2392,28 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio)
|
|||||||
WOLFSSL_ENTER("wolfSSL_BIO_new_connect");
|
WOLFSSL_ENTER("wolfSSL_BIO_new_connect");
|
||||||
bio = wolfSSL_BIO_new(wolfSSL_BIO_s_socket());
|
bio = wolfSSL_BIO_new(wolfSSL_BIO_s_socket());
|
||||||
if (bio) {
|
if (bio) {
|
||||||
const char* port = XSTRSTR(str, ":");
|
const char* port;
|
||||||
|
#ifdef WOLFSSL_IPV6
|
||||||
|
const char* ipv6Start = XSTRSTR(str, "[");
|
||||||
|
const char* ipv6End = XSTRSTR(str, "]");
|
||||||
|
|
||||||
|
if (ipv6End)
|
||||||
|
port = XSTRSTR(ipv6End, ":");
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
port = XSTRSTR(str, ":");
|
||||||
|
|
||||||
if (port != NULL)
|
if (port != NULL)
|
||||||
bio->port = (word16)XATOI(port + 1);
|
bio->port = (word16)XATOI(port + 1);
|
||||||
else
|
else
|
||||||
port = str + XSTRLEN(str); /* point to null terminator */
|
port = str + XSTRLEN(str); /* point to null terminator */
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_IPV6
|
||||||
|
if (ipv6Start && ipv6End) {
|
||||||
|
str = ipv6Start + 1;
|
||||||
|
port = ipv6End;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bio->ip = (char*)XMALLOC(
|
bio->ip = (char*)XMALLOC(
|
||||||
(size_t)(port - str) + 1, /* +1 for null char */
|
(size_t)(port - str) + 1, /* +1 for null char */
|
||||||
bio->heap, DYNAMIC_TYPE_OPENSSL);
|
bio->heap, DYNAMIC_TYPE_OPENSSL);
|
||||||
|
Reference in New Issue
Block a user