Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!lll-lcc!pyramid!oliveb!tymix!feldman From: feldman@tymix.UUCP (Steve Feldman) Newsgroups: comp.bugs.4bsd Subject: gethostby* library bug in 4.3BSD Message-ID: <858@tymix.UUCP> Date: Mon, 10-Nov-86 20:37:36 EST Article-I.D.: tymix.858 Posted: Mon Nov 10 20:37:36 1986 Date-Received: Tue, 11-Nov-86 06:29:21 EST Reply-To: feldman@tymix.UUCP (Steve Feldman) Distribution: world Organization: Tymnet Inc., Cupertino CA Lines: 49 Subject: gethostby* routines fail if no nameserver and using virtual circuits Index: lib/libc/net/res_send.c 4.3BSD Description: The gethostbyname() and gethostbyaddr() routines fail if there is no nameserver running and sethostent(1) is called to try to use a virtual circuit to the nameserver. This is because res_send() is incorrectly modifying the errno code after a virtual circuit connect fails. Repeat-By: Run "netstat -i" on a machine using /etc/hosts without the nameserver running. Fix: Apply the following patch to res_send.c. Then recompile netstat and systat in /usr/src/ucb, and anything else which does a sethostent(1). *** /usr/src/lib/libc/net/res_send.c Wed May 7 15:28:05 1986 --- res_send.c Mon Nov 10 15:46:25 1986 *************** *** 260,271 **** } } } ! (void) close(s); s = -1; ! if (v_circuit == 0 && gotsomewhere == 0) ! errno = ECONNREFUSED; ! else ! errno = ETIMEDOUT; return (-1); } --- 260,274 ---- } } } ! if (s >= 0) ! (void) close(s); s = -1; ! if (v_circuit == 0) { ! if (gotsomewhere == 0) ! errno = ECONNREFUSED; ! else ! errno = ETIMEDOUT; ! } return (-1); }