]> git.meshlink.io Git - meshlink/commitdiff
Ensure only valid hostnames end up in the invitation URL.
authorGuus Sliepen <guus@meshlink.io>
Sun, 29 Sep 2019 09:38:09 +0000 (11:38 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sun, 29 Sep 2019 09:38:09 +0000 (11:38 +0200)
src/meshlink.c

index c4822cdfd07bc6c1a5ab27e87a4bffba984b825d..f0a1b759fe989397c288149600f4fbb2e8316938 100644 (file)
@@ -333,7 +333,7 @@ void remove_duplicate_hostnames(char *host[], char *port[], int n) {
                        break;
                }
 
-               if(found) {
+               if(found || !is_valid_hostname(host[i])) {
                        free(host[i]);
                        free(port[i]);
                        host[i] = NULL;
@@ -417,7 +417,7 @@ static char *get_my_hostname(meshlink_handle_t *mesh, uint32_t flags) {
                        char resolved_port[NI_MAXSERV];
                        err = getnameinfo(ai_in->ai_addr, ai_in->ai_addrlen, resolved_host, sizeof resolved_host, resolved_port, sizeof resolved_port, NI_NUMERICSERV);
 
-                       if(err) {
+                       if(err || !is_valid_hostname(resolved_host)) {
                                freeaddrinfo(ai_in);
                                continue;
                        }