From 4ac017d4c4424a1a3c5c1b1c641cf1c29bd13e44 Mon Sep 17 00:00:00 2001 From: sairoop-elear Date: Thu, 12 Mar 2020 13:54:45 +0530 Subject: [PATCH] Fix IPv6 address validation bug preventing IPv6 addresses that are added for invitation from getting added --- src/meshlink.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/meshlink.c b/src/meshlink.c index f87e4de0..e7e7d5c8 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -442,7 +442,7 @@ static char *get_my_hostname(meshlink_handle_t *mesh, uint32_t flags) { if(mesh->invitation_addresses) { for list_each(char, combo, mesh->invitation_addresses) { hostname[n] = xstrdup(combo); - char *colon = strchr(hostname[n], ':'); + char *colon = strrchr(hostname[n], ':'); if(colon) { *colon = 0; @@ -2469,11 +2469,7 @@ bool meshlink_add_invitation_address(struct meshlink_handle *mesh, const char *a char *combo; if(port) { - if(strchr(address, ':')) { - xasprintf(&combo, "[%s]:%s", address, port); - } else { - xasprintf(&combo, "%s:%s", address, port); - } + xasprintf(&combo, "%s:%s", address, port); } else { combo = xstrdup(address); } -- 2.39.2