]> git.meshlink.io Git - meshlink/commitdiff
Fix IPv6 address validation bug preventing IPv6 addresses that are added for invitati...
authorsairoop-elear <sairoop@elear.solutions>
Thu, 12 Mar 2020 08:24:45 +0000 (13:54 +0530)
committerGuus Sliepen <guus@meshlink.io>
Thu, 12 Mar 2020 20:16:42 +0000 (21:16 +0100)
src/meshlink.c

index f87e4de0ec8326d34c07cc5b6b9a196ea10adbda..e7e7d5c80a1adeca69e662c4ec43063e4ab6ec46 100644 (file)
@@ -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);
        }