Bug 139734 - [libc] res_send calls getsockname(2) instead of getpeername(2)
Summary: [libc] res_send calls getsockname(2) instead of getpeername(2)
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-18 22:40 UTC by michaels-freebsd-bug
Modified: 2018-05-21 00:02 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description michaels-freebsd-bug 2009-10-18 22:40:05 UTC
On line 357 in src/lib/libc/resolv/res_send.c,v 1.8.2.1.2.1
the code calls _getsockname(2) to see if the old peer is the same
as the new peer (the nameserver it plans to connect to).
This getsockname(2) call should however be getpeername(2), as that
is what gives the remote peeraddress.

Fix: 

replace the getsockname(2) call with getpeername(2).
How-To-Repeat: Not so easy as this bug does not cause a direct problem, but rather
a needless close(2), socket(2), and connect(3) for repeated i/o
with the same nameserver. 

Unfortunatly it creates a more serious problem in a larger third-party
application.
Comment 1 michaels-freebsd-bug 2015-09-26 16:29:52 UTC
Bug still present in 10.1-release.
Comment 2 Jilles Tjoelker freebsd_committer freebsd_triage 2015-09-26 22:44:44 UTC
Hmm? It looks like SVN r270838, which is included in 10.1-RELEASE, changed getsockname to getpeername in that location.
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:59:45 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"