From 35859f3a2fc118620257505bd9ebd1b6388a38b6 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Thu, 14 May 2015 10:33:33 +0000 Subject: [PATCH] whois: do not clobber command-line flags when tweaking O_NONBLOCK This can make whois fail to follow referrals when it should. The bug was introduced in r281959. --- usr.bin/whois/whois.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c index 9fdd0070612d..824138cfb49e 100644 --- a/usr.bin/whois/whois.c +++ b/usr.bin/whois/whois.c @@ -311,7 +311,7 @@ whois(const char *query, const char *hostname, int flags) FILE *fp; struct addrinfo *hostres, *res; char *buf, *host, *nhost, *p; - int s = -1; + int s = -1, f; nfds_t i, j; size_t c, len, count; struct pollfd *fds; @@ -431,9 +431,9 @@ whois(const char *query, const char *hostname, int flags) if (s != -1) { /* Restore default blocking behavior. */ - if ((flags = fcntl(s, F_GETFL)) != -1) { - flags &= ~O_NONBLOCK; - if (fcntl(s, F_SETFL, flags) == -1) + if ((f = fcntl(s, F_GETFL)) != -1) { + f &= ~O_NONBLOCK; + if (fcntl(s, F_SETFL, f) == -1) err(EX_OSERR, "fcntl()"); } else err(EX_OSERR, "fcntl()");