From 1a755d0da2075ba0cccaaacd616f31eec697b08a Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 19 Jun 2021 15:56:39 +0200 Subject: uri: hostname_is_localhost(): don’t crash if hostname == NULL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uri.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'uri.c') diff --git a/uri.c b/uri.c index 51cd8093..e747991d 100644 --- a/uri.c +++ b/uri.c @@ -270,7 +270,8 @@ hostname_is_localhost(const char *hostname) if (gethostname(this_host, sizeof(this_host)) < 0) this_host[0] = '\0'; - return (strcmp(hostname, "") == 0 || - strcmp(hostname, "localhost") == 0 || - strcmp(hostname, this_host) == 0); + return (hostname != NULL && ( + strcmp(hostname, "") == 0 || + strcmp(hostname, "localhost") == 0 || + strcmp(hostname, this_host) == 0)); } -- cgit v1.3