From: Guus Sliepen Date: Sun, 29 Sep 2019 09:38:09 +0000 (+0200) Subject: Ensure only valid hostnames end up in the invitation URL. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=fe75ca04fafa140c4fec90b61dac669d271e2acf;p=meshlink Ensure only valid hostnames end up in the invitation URL. --- diff --git a/src/meshlink.c b/src/meshlink.c index c4822cdf..f0a1b759 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -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; }