NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/46454: getnameinfo(3) is not thread-safe

>Number:         46454
>Category:       lib
>Synopsis:       getnameinfo(3) is not thread-safe
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 15 07:10:00 +0000 2012
>Originator:     Yui NARUSE
>Release:        6.99.4
NetBSD 6.99.4 NetBSD 6.99.4 (GENERIC) #0: Fri Apr 13 00:47:23 
JST 2012 i386
SuS says getnameinfo(3) shall be thread-safe.
But NetBSD's getnameinfo(3) uses gethostbyaddr(3), which is not thread-safe.
(gethostbyname is removed in SuSv7)

getnameinfo() calls getpeername(),
getpeername() calls nsdispatch(),
nsdispatch() calls _gethtbyaddr() with rdlock,
_gethtbyaddr() calls _gethtent().
_gethtent() uses static variable hostf.
If someone calls _endhtent() during one runs _gethtent(),
_endhtent() sets NULL to hostf, and _gethtent() will cause SEGV.

The original issue is derived from Ruby's test case
and this report is helped by enami.


Home | Main Index | Thread Index | Old Index