From: sairoop-elear Date: Thu, 12 Mar 2020 08:24:45 +0000 (+0530) Subject: Fix IPv6 address validation bug preventing IPv6 addresses that are added for invitati... X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=4ac017d4c4424a1a3c5c1b1c641cf1c29bd13e44;p=meshlink Fix IPv6 address validation bug preventing IPv6 addresses that are added for invitation from getting added --- 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); }