From patchwork Fri Jun 7 06:39:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13689356 Received: from fout1-smtp.messagingengine.com (fout1-smtp.messagingengine.com [103.168.172.144]) (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 9CBDD154BFC for ; Fri, 7 Jun 2024 06:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717742358; cv=none; b=dyP3vrGM0sanE8+morbd9Tnb33kCU6+cG7hILgNRcoOK5ejZi8TokVMBi7cxN0tLTbOgnWmNYKKhUBD+7xrKXy+d7ml18YbMXH3xJu3MmY0779Rt9iTLdRRZ4uowIpv2X/sdCRFK0nDHRTYWhykYDXOV9N+tyUKi45WT0B7DYT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717742358; c=relaxed/simple; bh=JkuE6Qi1kMzmmeQznGDSZ1EJsL85SDJr+4UYMndQO+8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z7OQDnH3E5XTUi3oIYRuebMVwioG5Ytmv6ekbsrPaOVZfdJSbRAMtXslhN4PNf8SvKQi8RsO/Uw2rxwe+DTkkPEMi7qmZMGd/syvrtiKw0Rg9KttJQwhQcUky2DDDJoIi1HcdLIQy3DUi98S5Jsn8TylBfJeMu5YUrFlnkFPTak= 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=Fxq9LanF; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=gnQmxGz7; arc=none smtp.client-ip=103.168.172.144 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="Fxq9LanF"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="gnQmxGz7" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id C5FCD13801ED; Fri, 7 Jun 2024 02:39:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 07 Jun 2024 02:39:15 -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=1717742355; x=1717828755; bh=SUBWm2opj6 PpXrW1m/zDiziM1t4dTjfIFOLIRSt+1+A=; b=Fxq9LanF9x2JHcJiLGZmYNOOxk uPTm5TP/C5JQ8Twfxa4t9MsjcJdnTtl6Fszgwyxp94pN7gui/SSAAUWBJJSPYjh+ boNTgKVQuCjEu19VZkVDPuxpPUXCjiBJhnz0ItsF6zQ66uZ1EezJ+ZO1UUnp4n+3 QhpFg9uCZk7crSO03UXMCDLyWHOGcav1SGUhJOP84Rc3zaeXj8RotARdWLv10Zux z0R9NqeEftwVxPTotPr4/OIGOF7uOxPsjPt93WFZxP4mz3mdKNv1ARxt1XXgZuKJ Z0Xp1JJqZOsmRwegaLzLXhD5/8RXaUpuB6GKwUOjcynYKRP3eNHvnnMizDfA== 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=1717742355; x=1717828755; bh=SUBWm2opj6PpXrW1m/zDiziM1t4d TjfIFOLIRSt+1+A=; b=gnQmxGz7oIDD4oUuO12XYWDsTwHWOIK30quwx65nR6c2 sWUMB2yZqojhMNKgq/uWH84g7XGDFlVOXXLIWDyQXHdZdXQ9hLnLG7zMUukOG2Gz DRvvM3TnlW1PhBJH2Eskp8KT6DICB/gHLjDVwFB4RXbHYDQ4c2BCicYMPRdpGAG3 6YL77OxOAFbaxaBejodqnKWdcoGnEpT4qvK6g7Up/0zEp7eX6x/WLnQ0HYCBVKaK Mq1Uybh4/wIDVMgouzSrOMlBhXJmpplFVyxIaMFBpYL3YtRcox9D3B4UblcCq/Zy GMjd4nWEMzvpOW6/M6EpSlFKdQez4AWYZai2WeExTQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelledguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrght rhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtth gvrhhnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleff teenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpsh esphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Jun 2024 02:39:14 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 63351a3e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 7 Jun 2024 06:39:13 +0000 (UTC) Date: Fri, 7 Jun 2024 08:39:12 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Eric Sunshine Subject: [PATCH v6 21/27] mailmap: always store allocated strings in mailmap blob Message-ID: <2bb96449e2a65f3398048b3430822bc7b95d31f0.1717740366.git.ps@pks.im> 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",