Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Oct 2009 23:10:27 +0200
From:      Michael Shuldman <michaels-freebsd-bug@inet.no>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   misc/139734: res_send calls getsockname(2) instead of getpeername(2)
Message-ID:  <20091018211027.GA30941@kosmo.inet.no>
Resent-Message-ID: <200910182140.n9ILe6vR031362@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         139734
>Category:       misc
>Synopsis:       res_send calls getsockname(2) instead of getpeername(2)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 18 21:40:05 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Michael Shuldman
>Release:        FreeBSD 7.2-RELEASE i386
>Organization:
Inferno Nettverk A/S, Oslo, Norway; http://www.inet.no
>Environment:
System: FreeBSD foss.inet.no 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May 1 08:49:13 UTC 2009 root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386


	<machine, os, target, libraries (multiple lines)>
>Description:
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.


>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.


>Fix:
replace the getsockname(2) call with getpeername(2).


>Release-Note:
>Audit-Trail:
>Unformatted:



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