From nobody Fri Feb 25 15:31:06 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6625719CC1EB; Fri, 25 Feb 2022 15:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K4tyz1SPhz4Wl2; Fri, 25 Feb 2022 15:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645803067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9zsKHSYBbBU6C+7Zv1svYV/0B8xvhwpWwAKHb0RHmjI=; b=Sjk5WO6XeMX935zqdj8x+3KMCXgpqoyh2aF44D7baNwJghGLHY9feCpr8vlm2thwfXyMnr hSdkJQbcy0gKdpIT32MLhvyNr9rrIRT4KVRbzDUBKlxI6dS6zwBAHbYJmsWbSxDeDXR+po 5/GlYcTE/pfFlEXJggbPYhBEKqK0ZYTilpSs5LuwhN80b4kHsD2ueAtNTeAFfab14li9ss Izl8H/96OjlcdJLxjdRndYqNpPt+hPN9bfwOjXoenLrB6qCQ9QIiIG5hvN2bCYLwBxEzTq WspYqFYdnJUSyKZABDvrB2TiZRG8qvuZRASl1aP+FJ6FdniArEI6BVuBPzp75Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0BAC62229B; Fri, 25 Feb 2022 15:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21PFV6N4076243; Fri, 25 Feb 2022 15:31:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21PFV6Za076242; Fri, 25 Feb 2022 15:31:06 GMT (envelope-from git) Date: Fri, 25 Feb 2022 15:31:06 GMT Message-Id: <202202251531.21PFV6Za076242@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: 331b84b5db11 - main - rtsold: fix memory leak in script execution List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 331b84b5db11b17d1bb0cdbce986efb587a1e5ee Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645803067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9zsKHSYBbBU6C+7Zv1svYV/0B8xvhwpWwAKHb0RHmjI=; b=lfRuhcQpfyBwFxD55uqp1lnA/ii1Ip2FUmV3ERVbfhVOCIXwnLdKeYWjg2H/e7XodW6XB0 FZ8ARle9Syt6vj9OpyvG5vjmOdPfQeglhpAk2FrqNsXBjgxB7fIL8Y8b0Hw0FV0XdhguS2 zxq7lF0z8qrE0oc+/EUiWmPfe09+o72PN3mFfZRMxl9SOnrJuJvf0m64hvz20pZsgic1cM hbAtKCdciRxEr+/bccnO66gxcjqSpxnBm7Y0sBHrmk7zaEjjsuFPInzGfIFbBCCmU3UMbv Hsgx9jz5zOa2pKPNJ/SIVrjdfujTKBgUT7xeJnO4tvR6UkX2HxqaUD0DkN1BWw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645803067; a=rsa-sha256; cv=none; b=gaSg5tEcclNCRdz53JKsMd7r/u7HX1tWs3zLMI6+lCpCcoeWa/FNoOf3RoLMgHq7bCKLeW v7osnRGaxy1kOhv8iLTOUZCDCssj+f7LWuBkfvpxHFGsDXts1CKLZevOQ/9obug0HV6Ujs 9UhLxibNpWXdsF33cU3bsJLtAtG43QB/Nk63vOfDtr6MxOGMahGaYT/yHi8HOA6+lhLPiQ 3kC9P0SIKCC8YBoPv6kHRcgtOfj+Ukk5TXNUssZVW51sZOSBz3qpNn/38zGcbLoxGSl3iv 5zal6UFg+YZ++NJaicJFd/vEZjpvDnPxBxaQLCU9GpK3hHJaNA4D4kBGxlKgFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=331b84b5db11b17d1bb0cdbce986efb587a1e5ee commit 331b84b5db11b17d1bb0cdbce986efb587a1e5ee Author: Eric van Gyzen AuthorDate: 2022-02-23 16:49:12 +0000 Commit: Eric van Gyzen CommitDate: 2022-02-25 15:30:29 +0000 rtsold: fix memory leak in script execution Since commit 04e9edb54428, rtsold has leaked the memory for the argument vector of every script it runs. Reported by: Coverity Reviewed by: markj Fixes: 04e9edb5442826a14616157962361ff81e4a38fe MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D34355 --- usr.sbin/rtsold/cap_script.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rtsold/cap_script.c b/usr.sbin/rtsold/cap_script.c index 5594d8ec8ec5..971d0bae4172 100644 --- a/usr.sbin/rtsold/cap_script.c +++ b/usr.sbin/rtsold/cap_script.c @@ -162,7 +162,7 @@ script_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin, const char *const *iargv, *const *scripts; char **argv; size_t argc, i, nscripts; - int fd, status; + int error, fd, status; if (strcmp(cmd, "script_wait") == 0) { /* Wait for the result of a previous "script_run" command. */ @@ -198,8 +198,10 @@ script_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin, memcpy(argv, iargv, sizeof(*argv) * argc); fd = script_run(argv); + error = errno; + free(argv); if (fd < 0) - return (errno); + return (error); (void)caph_rights_limit(fd, cap_rights_init(&rights, CAP_WRITE)); nvlist_move_descriptor(nvlout, "fd", fd);