From 6836a0f2774190d624cc1620391ab02cd0c3db4e Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Wed, 18 Sep 2019 21:18:01 +0200 Subject: [PATCH] [mdns] Fix incorrect error check for getaddrinfo (can cause segfault) Non-zero return from getaddrinfo is an error, so since *ai could be a null pointer when derefenced in the following socket() call. --- src/mdns_avahi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mdns_avahi.c b/src/mdns_avahi.c index 87c0bc44..11a0e122 100644 --- a/src/mdns_avahi.c +++ b/src/mdns_avahi.c @@ -498,7 +498,7 @@ connection_test(int family, const char *address, const char *address_log, int po snprintf(strport, sizeof(strport), "%d", port); ret = getaddrinfo(address, strport, &hints, &ai); - if (ret < 0) + if (ret != 0) { DPRINTF(E_WARN, L_MDNS, "Connection test to %s:%d failed with getaddrinfo error: %s\n", address_log, port, gai_strerror(ret)); return -1;