Skip to content

Commit 4d4228c

Browse files
authored
Merge pull request wolfSSL#8815 from kareem-wolfssl/zd19929
Fix wolfSSL_BIO_new_connect's handling of IPV6 addresses.
2 parents 047d1bd + c9d451e commit 4d4228c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/bio.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,13 +2392,28 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio)
23922392
WOLFSSL_ENTER("wolfSSL_BIO_new_connect");
23932393
bio = wolfSSL_BIO_new(wolfSSL_BIO_s_socket());
23942394
if (bio) {
2395-
const char* port = XSTRSTR(str, ":");
2395+
const char* port;
2396+
#ifdef WOLFSSL_IPV6
2397+
const char* ipv6Start = XSTRSTR(str, "[");
2398+
const char* ipv6End = XSTRSTR(str, "]");
2399+
2400+
if (ipv6End)
2401+
port = XSTRSTR(ipv6End, ":");
2402+
else
2403+
#endif
2404+
port = XSTRSTR(str, ":");
23962405

23972406
if (port != NULL)
23982407
bio->port = (word16)XATOI(port + 1);
23992408
else
24002409
port = str + XSTRLEN(str); /* point to null terminator */
24012410

2411+
#ifdef WOLFSSL_IPV6
2412+
if (ipv6Start && ipv6End) {
2413+
str = ipv6Start + 1;
2414+
port = ipv6End;
2415+
}
2416+
#endif
24022417
bio->ip = (char*)XMALLOC(
24032418
(size_t)(port - str) + 1, /* +1 for null char */
24042419
bio->heap, DYNAMIC_TYPE_OPENSSL);

0 commit comments

Comments
 (0)