[Bug 200580] superfluous/unnecessary endhostent() does close(0) by accident. libc resolver dns fd close

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Jun 1 21:09:26 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200580

            Bug ID: 200580
           Summary: superfluous/unnecessary endhostent() does close(0) by
                    accident. libc resolver dns fd close
           Product: Base System
           Version: 10.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: oh5nxo at gmail.com

Calling endhostent(), when such a call is not needed,
ends up closing fd 0 by accident.

main()
{
        endhostent();
}

Breakpoint 2, 0x281a8dc0 in close () from /lib/libc.so.7
(gdb) where
#0  0x281a8dc0 in close () from /lib/libc.so.7
#1  0x28152518 in __res_nclose () from /lib/libc.so.7
#2  0x2817c585 in __dns_getanswer () from /lib/libc.so.7
#3  0x080485b3 in main () at endhostent_bug.c:4

hopo $ truss ./a.out
...
close(0)                                         = 0 (0x0)
...
process exit, rval = 0

Except the usual runtime chores, close(0) is the only visible systemcall.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list