Date: Fri, 21 Feb 2020 18:21:57 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358227 - head/lib/libfetch Message-ID: <202002211821.01LILvRV065104@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Fri Feb 21 18:21:57 2020 New Revision: 358227 URL: https://svnweb.freebsd.org/changeset/base/358227 Log: fetch(3): plug some leaks In the successful case, sockshost is not freed prior to return. The failure case can now be hit after fetch_reopen(), which was not true before. Thus, we need to make sure to clean up all of the conn resources which will also close sd. For all of the points prior to fetch_reopen(), we continue to just close sd. CID: 1419598, 1419616 Modified: head/lib/libfetch/common.c Modified: head/lib/libfetch/common.c ============================================================================== --- head/lib/libfetch/common.c Fri Feb 21 16:55:28 2020 (r358226) +++ head/lib/libfetch/common.c Fri Feb 21 18:21:57 2020 (r358227) @@ -677,6 +677,7 @@ fetch_connect(const char *host, int port, int af, int if (sockshost) if (!fetch_socks5_init(conn, host, port, verbose)) goto fail; + free(sockshost); if (cais != NULL) freeaddrinfo(cais); if (sais != NULL) @@ -686,7 +687,10 @@ syserr: fetch_syserr(); fail: free(sockshost); - if (sd >= 0) + /* Fully close if it was opened; otherwise just don't leak the fd. */ + if (conn != NULL) + fetch_close(conn); + else if (sd >= 0) close(sd); if (cais != NULL) freeaddrinfo(cais);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002211821.01LILvRV065104>