From fe75ca04fafa140c4fec90b61dac669d271e2acf Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 29 Sep 2019 11:38:09 +0200 Subject: [PATCH] Ensure only valid hostnames end up in the invitation URL. --- src/meshlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } -- 2.39.5