From michaels-freebsd-bug-dated-1256332231.0ccf2e@inet.no Sun Oct 18 21:37:14 2009 Return-Path: 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 Reply-To: Michael Shuldman To: FreeBSD-gnats-submit@freebsd.org Subject: res_send calls getsockname(2) instead of getpeername(2) X-Send-Pr-Version: 3.113 >Number: 139734 >Category: kern >Synopsis: [libc] 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: Mon Oct 19 02:02:32 UTC 2009 >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: