From: Guus Sliepen Date: Tue, 10 Mar 2020 21:33:42 +0000 (+0100) Subject: Ensure we process all hostnames for invitation URLs. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=494e5cfca22e2e8fc59a42b01d4a94418d730c2a;p=meshlink Ensure we process all hostnames for invitation URLs. Commit 3febbb4 allowed more addresses to be added to invitation URLs, but part of the still code assumed a maximum of 4 addresses in the URL. --- diff --git a/src/meshlink.c b/src/meshlink.c index 6e7cda60..b9cc1877 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -482,7 +482,7 @@ static char *get_my_hostname(meshlink_handle_t *mesh, uint32_t flags) { } } - for(int i = 0; i < 4; i++) { + for(int i = 0; i < n; i++) { // Ensure we always have a port number if(hostname[i] && !port[i]) { port[i] = xstrdup(mesh->myport); @@ -492,7 +492,7 @@ static char *get_my_hostname(meshlink_handle_t *mesh, uint32_t flags) { remove_duplicate_hostnames(hostname, port, 4); // Resolve the hostnames - for(int i = 0; i < 4; i++) { + for(int i = 0; i < n; i++) { if(!hostname[i]) { continue; } @@ -554,10 +554,10 @@ static char *get_my_hostname(meshlink_handle_t *mesh, uint32_t flags) { } // Remove duplicates again, since IPv4 and IPv6 addresses might map to the same hostname - remove_duplicate_hostnames(hostname, port, 4); + remove_duplicate_hostnames(hostname, port, n); // Concatenate all unique address to the hostport string - for(int i = 0; i < 4; i++) { + for(int i = 0; i < n; i++) { if(!hostname[i]) { continue; }