From patchwork Tue Jun 4 12:38:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13685187 Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30ECC146A87 for ; Tue, 4 Jun 2024 12:38:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717504721; cv=none; b=dHDTSyD7/gJJhsE8X6ddTJOO53PZW2ud8Zam+ByXJa+jEQj3TJ89ppEs0MtsG8gP43OU8e9aCWdcK0EtEyC3v+vFJyT1gdi8Y1rNt65YQyl9Ozsiw4IqN+QCA67iZCjQFMnjRvFDffDdygzkqAP47+5i4MS/cWkN7J8ZMG+k8jU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717504721; c=relaxed/simple; bh=jhSVqpK7ZPDOQ5FUGRwSbdzk2eN5+G+DEfRgeGsu3vc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OaQcz0j2B2NzjWbaXxy1LGrLUIgFUdNMaM9yjkAvIS5utAmDf/ekzcMkEagIwc7xgAZWOHKWcUYAjGnZQFUAheO3VFGNAOPmpcEoU/l/H6HD+fM+09adXJCjCkWyeHeNx46czKDF01L8ECrX/AoFQ6etCM6vy4NrkjR8NkT7Cnk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=VHmd5DGQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cnJAlgSV; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="VHmd5DGQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cnJAlgSV" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 528A811400DB; Tue, 4 Jun 2024 08:38:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 04 Jun 2024 08:38:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1717504719; x=1717591119; bh=EOdldt/KB8 FZ+pE61RMrFEAhho4DHIAgmFzgns35j6k=; b=VHmd5DGQnJ3ZrbQcYRAJBCpdi1 u91sDoQqs63kuebAM3NnHei/qOejPvq0FcN0j2m6BB1oOFrnNguVBBR+bQXnEpM/ 6xtt5zV+ORTY8EoRO7GVGdPq4I6AeWyu13xZtPGWMA2ZbGzZ9tNFPZ8shi3AxYyy vExp7/Pr2wq/LcOO7iVvUGQbz8UBlx87BZCROGbJ/j8qvn2OyCp6klMA18C9qpjA PBRBArOO92aNPdqV1eBL/M5R1AWb5Gyu7ACVetzarjXO+xDGVxupWYZs8Pxr6x9g gA1tR9cb9wmY5rw+XhJemtYEH3QBjWFjsUrZkq7Z85oRqP1Nc4vFrol2yCig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1717504719; x=1717591119; bh=EOdldt/KB8FZ+pE61RMrFEAhho4D HIAgmFzgns35j6k=; b=cnJAlgSVWidsssRmY0kvU7O3rDncVO3vGgT0Btikj/Bu SK/oAyHGt2AMrzN1qkCZGx8lttOpn4+r8Hc/SOdYixpgNSonX2Q4AaFFuxb8zDhH Kq/D98XtZl5bBZ9n2g5m58ZRsQWASyrsrqGdtmwSknN0xCyFy6im9xpnbxghzxiG rNHd3BI3bxe2bDFzqPra+b0Lc6MvT7kzwkxnxwPCgFLEzL77WkCgwW38M+WR/A7F WJvY0pIa0bsgx/EFus+RQJkrV4YPf37FxT/ZEUblYGIu29UFDQWF9uA4b7LYjG9B zYgWg2o8liVuorD1FylwGrK1xmorZa6tq8KfeC2SmQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelgedghedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Jun 2024 08:38:38 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 40823236 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 4 Jun 2024 12:38:10 +0000 (UTC) Date: Tue, 4 Jun 2024 14:38:35 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Eric Sunshine Subject: [PATCH v4 21/27] mailmap: always store allocated strings in mailmap blob Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Same as with the preceding commit, the `git_mailmap_blob` may sometimes contain an allocated string and sometimes it may contain a string constant. This is risky and can easily lead to bugs in case the variable is getting re-assigned, where the code may then try to free the previous value to avoid memory leaks. Safeguard the code by always storing allocated strings in the variable. Signed-off-by: Patrick Steinhardt --- mailmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mailmap.c b/mailmap.c index b2efe29b3d..3d1e092fef 100644 --- a/mailmap.c +++ b/mailmap.c @@ -216,7 +216,7 @@ int read_mailmap(struct string_list *map) map->cmp = namemap_cmp; if (!git_mailmap_blob && is_bare_repository()) - git_mailmap_blob = "HEAD:.mailmap"; + git_mailmap_blob = xstrdup("HEAD:.mailmap"); if (!startup_info->have_repository || !is_bare_repository()) err |= read_mailmap_file(map, ".mailmap",