From owner-svn-src-all@FreeBSD.ORG Sat Dec 19 19:22:10 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C4D21065676; Sat, 19 Dec 2009 19:22:10 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0ABDB8FC17; Sat, 19 Dec 2009 19:22:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBJJM9nB041417; Sat, 19 Dec 2009 19:22:09 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBJJM9gJ041415; Sat, 19 Dec 2009 19:22:09 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200912191922.nBJJM9gJ041415@svn.freebsd.org> From: Attilio Rao Date: Sat, 19 Dec 2009 19:22:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200734 - stable/8/lib/libfetch X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Dec 2009 19:22:10 -0000 Author: attilio Date: Sat Dec 19 19:22:09 2009 New Revision: 200734 URL: http://svn.freebsd.org/changeset/base/200734 Log: MFC r199801: Fix a socket leak. Sponsored by: Sandvine Incorporated Modified: stable/8/lib/libfetch/ftp.c Directory Properties: stable/8/lib/libfetch/ (props changed) Modified: stable/8/lib/libfetch/ftp.c ============================================================================== --- stable/8/lib/libfetch/ftp.c Sat Dec 19 19:01:24 2009 (r200733) +++ stable/8/lib/libfetch/ftp.c Sat Dec 19 19:22:09 2009 (r200734) @@ -1122,17 +1122,19 @@ ftp_request(struct url *url, const char /* change directory */ if (ftp_cwd(conn, url->doc) == -1) - return (NULL); + goto errsock; /* stat file */ if (us && ftp_stat(conn, url->doc, us) == -1 && fetchLastErrCode != FETCH_PROTO && fetchLastErrCode != FETCH_UNAVAIL) - return (NULL); + goto errsock; /* just a stat */ - if (strcmp(op, "STAT") == 0) + if (strcmp(op, "STAT") == 0) { + ftp_disconnect(conn); return (FILE *)1; /* bogus return value */ + } if (strcmp(op, "STOR") == 0 || strcmp(op, "APPE") == 0) oflag = O_WRONLY; else @@ -1140,6 +1142,10 @@ ftp_request(struct url *url, const char /* initiate the transfer */ return (ftp_transfer(conn, op, url->doc, oflag, url->offset, flags)); + +errsock: + ftp_disconnect(conn); + return (NULL); } /*