From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-4.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 Received: by atuin.qyliss.net (Postfix, from userid 496) id 6093BBAB8; Sun, 21 Mar 2021 14:51:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 7C345BAA3; Sun, 21 Mar 2021 14:51:43 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 12CA3BA11; Sun, 21 Mar 2021 14:51:41 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by atuin.qyliss.net (Postfix) with ESMTPS id 9F7D2BA10 for ; Sun, 21 Mar 2021 14:51:38 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id DEDC25C00CF; Sun, 21 Mar 2021 10:51:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 21 Mar 2021 10:51:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=h+iyBX2UhvUBL UyB3DO/dzi5XwSBs8+rLa9Sxdiza1g=; b=aBK9x0iyVckUzey6aORUH7gSw6Ypk +66Y43JwIa9lWWssVhva1ZfpMQlI21TAoOtGLRZmuI8HZKi5c1eyYP17X0AEUkZe 7UaZbAjuSLESbBzvXFTS9L91HO2FcBgp2nWU+jqIkoJi1vXihri4YsOtbaaRYVDk HmlRG+dWw2/z8LxQ3S9RTWBIeoaN72gJQ51llBtTawfYjFw97p5m1CluaB762HBh jNsqufTV6yroRmfmLgrtwkP9zEcOFDtRmeyuIMf7sTfsHwz4nMrHQ1eZSAf4FrPX +uEjHOwmpmbq3Skln8Sr4bXVVnQ06EBCEvaGBTvFJjOYqKXLSy7mzOrBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=h+iyBX2UhvUBLUyB3DO/dzi5XwSBs8+rLa9Sxdiza1g=; b=jti7VMU1 GTk4tle4MnVOvh6Sm9YvBA0e3LLIQ6saf21COXY8JB24mJnWxK6pPFLbdB0zttwJ tKsHo2wUQoqugPXsLZMb9XQwH+ZSqUdVil+qF9eo9AZC5Hk8uBa1ZAkitVNUNg+T r9xN9Sl5LuEXy5XHSIUpWT2ini5x+iToiWs9Bqpc05cFNV85F6zveKY9eBo8iXBT V97RtgpzQiFaFvBJafLzOoPND3A1jQSVLkF5DpAQ4L0JoIUM3hOO7JuZDDF3q5r0 osY43XoWPkP0wrJ81+q32QzYw3cN5/zw5df88vjl3A4fIeu+oKSFkzk2XKiW8/It 1TIdSQf4PwOBUw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegvddgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeetlhihshhs rgcutfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpefgfe dukedvleeileeludefveehgeelgfegvddujedvtdffueeuveffheeljeekvdenucfkphep jeelrddvfedurddvgeefrdekudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehqhihlihhsshesvghvvgdrqhihlhhishhsrdhnvght X-ME-Proxy: Received: from eve.qyliss.net (p4fe7f351.dip0.t-ipconnect.de [79.231.243.81]) by mail.messagingengine.com (Postfix) with ESMTPA id 96C05108005F; Sun, 21 Mar 2021 10:51:37 -0400 (EDT) Received: by eve.qyliss.net (Postfix, from userid 1000) id D3B93111C; Sun, 21 Mar 2021 14:51:35 +0000 (UTC) From: Alyssa Ross To: devel@spectrum-os.org Subject: [PATCH ucspi-vsock 1/2] exec: free argv if exec fails Date: Sun, 21 Mar 2021 14:51:17 +0000 Message-Id: <20210321145118.27783-1-hi@alyssa.is> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210321144700.24024-1-hi@alyssa.is> References: <20210321144700.24024-1-hi@alyssa.is> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: USSTQURFV34BTGP23HHWE2OFIMI4DAOK X-Message-ID-Hash: USSTQURFV34BTGP23HHWE2OFIMI4DAOK X-MailFrom: qyliss@eve.qyliss.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Cole Helbling X-Mailman-Version: 3.3.1 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Identified by clang-tidy: exec.c:21:2: warning: Potential leak of memory pointed to by 'argv' [clang-analyzer-unix.Malloc] return execvp(file, argv); ^ exec.c:15:16: note: Memory is allocated char **argv = calloc(argz_count(argz, len) + 1, sizeof(char *)); ^ exec.c:16:6: note: Assuming 'argv' is non-null if (!argv) ^ exec.c:16:2: note: Taking false branch if (!argv) ^ exec.c:21:2: note: Potential leak of memory pointed to by 'argv' return execvp(file, argv); --- I'm not used to thinking about allocations around exec, since usually if it fails the program just terminates. But in a function like this, the rules are a bit different. exec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index cc55200..75b1980 100644 --- a/exec.c +++ b/exec.c @@ -18,5 +18,8 @@ int execzp(const char *file, const char *argz, size_t len) argz_extract(argz, len, argv); - return execvp(file, argv); + execvp(file, argv); + + free(argv); + return -1; } -- 2.30.0