From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 18 21:40:06 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6253D106568F for ; Sun, 18 Oct 2009 21:40:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 41B8F8FC19 for ; Sun, 18 Oct 2009 21:40:06 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n9ILe63Z031363 for ; Sun, 18 Oct 2009 21:40:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n9ILe6vR031362; Sun, 18 Oct 2009 21:40:06 GMT (envelope-from gnats) Resent-Date: Sun, 18 Oct 2009 21:40:06 GMT Resent-Message-Id: <200910182140.n9ILe6vR031362@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Michael Shuldman Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0CA6A1065676 for ; Sun, 18 Oct 2009 21:37:14 +0000 (UTC) (envelope-from michaels-freebsd-bug-dated-1256332231.0ccf2e@inet.no) Received: from jensen.inet.no (jensen.inet.no [195.139.68.2]) by mx1.freebsd.org (Postfix) with SMTP id 5D4BA8FC0C for ; Sun, 18 Oct 2009 21:37:13 +0000 (UTC) Received: (qmail 20009 invoked by user); 18 Oct 2009 21:10:31 -0000 Received: by kosmo.inet.no (tmda-sendmail); Sun, 18 Oct 2009 23:10:31 +0200 (MEST) Message-Id: <20091018211027.GA30941@kosmo.inet.no> Date: Sun, 18 Oct 2009 23:10:27 +0200 From: Michael Shuldman To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: misc/139734: res_send calls getsockname(2) instead of getpeername(2) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Michael Shuldman List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2009 21:40:06 -0000 >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 >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: