]> git.meshlink.io Git - meshlink/commitdiff
Ensure we process all hostnames for invitation URLs.
authorGuus Sliepen <guus@meshlink.io>
Tue, 10 Mar 2020 21:33:42 +0000 (22:33 +0100)
committerGuus Sliepen <guus@meshlink.io>
Tue, 10 Mar 2020 21:33:42 +0000 (22:33 +0100)
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.

src/meshlink.c

index 6e7cda60a3f71fd1a94424c754af48a1288ae0c5..b9cc18771d22ef5f2c01eba18b38937f3619a4e8 100644 (file)
@@ -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);
                // 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
        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;
                }
                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 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
 
        // 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;
                }
                if(!hostname[i]) {
                        continue;
                }