From 42a79fde4cba9057fbefbce4fa02a540763fad94 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 15 Nov 2016 16:51:36 +1100 Subject: [PATCH] check the value of s (cherry picked from commit 28f344c18a0b9fbc5726472c03a953bfb8030f3b) --- bin/tests/system/feature-test.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/tests/system/feature-test.c b/bin/tests/system/feature-test.c index 8ccc8bf34b..3f7c7cb7f9 100644 --- a/bin/tests/system/feature-test.c +++ b/bin/tests/system/feature-test.c @@ -161,14 +161,16 @@ main(int argc, char **argv) { return (0); #elif defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) int s; - int n; + int n = -1; int v6only = -1; ISC_SOCKADDR_LEN_T len = sizeof(v6only); s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); - n = getsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, - (void *)&v6only, &len); - close(s); + if (s >= 0) { + n = getsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, + (void *)&v6only, &len); + close(s); + } return ((n == 0 && v6only == 0) ? 0 : 1); #else return (1);