Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 Jun 2015 21:09:26 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 200580] superfluous/unnecessary endhostent() does close(0) by accident. libc resolver dns fd close
Message-ID:  <bug-200580-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
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@FreeBSD.org
          Reporter: oh5nxo@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-200580-8>