From patchwork Mon Jun 3 09:40:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13683490 Received: from wfhigh7-smtp.messagingengine.com (wfhigh7-smtp.messagingengine.com [64.147.123.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 EA89385277 for ; Mon, 3 Jun 2024 09:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407643; cv=none; b=s19lOm0cysnEC4EwKo73pTeO1LO+lK/mc92tz3Yia5bX2AVGknd9B1E1loCXqXYp2a0WDbrez5/M6iyD+PUQvWzT6F4V8faWhjU+69FDPZTmgCVh/ltQe0TFbjwKWcTgJufW2Pj/Duuo1Bmne0+eFlFFjFZYzKkBB9pEbvy2ax4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717407643; c=relaxed/simple; bh=+NuBitQ6dhNaAsP8WDcZxSC0q24zbFi5leqFxAYRVSg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=caE77SnxabD0irxyeNDfR3yE84VCton1vLXRuYBkbM+YQSUwj3Hc1AQtDERH8kwcxAp59qmZcr+cOFucqGPK5Fox3HM7ow+dQnTU8TZpMKu9pGjCRp5c0L2Dmrk2wKU5+VdDAqzKr0La7iIiTYyssUaEW4Abb0lMEaUGIIVg5VI= 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=Si/3vTUf; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=iWZkEmGq; arc=none smtp.client-ip=64.147.123.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="Si/3vTUf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="iWZkEmGq" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id 1D66118000F6; Mon, 3 Jun 2024 05:40:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 03 Jun 2024 05:40:41 -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=1717407640; x=1717494040; bh=s9f8F7zj9a 5hMGScmVLaK5hp+BJI0KqfRM/mH7GW+Bs=; b=Si/3vTUft461K9anD/gCGf9Dl/ vMBDvjOIwZnMX7/K6IwTHtG95oqaJ1aPLu3NFM23DxAJXe6Wdxr13ZjwBU3/BnjL 8qtTSwiYPJiuFxRdgURuBvN7HvgvFIbv161QqXKFiu811o9+KxXSmR5hXCOgh0xg DVrkt4SOUlmEPSuU/kOtgufb2zICmOJ1TRM3cxiRm8TZr4C02SnjAwhntpHLcU3a PuRYX79Rtxmt0Ypi3g6TegN6WjijiXdEI7lm9mumP7wa9XnMv0dXlrQt4Tdi4fXr QINMuHqWDHlJEiOooSmUM+PdEhmPOKAAYL5DK5ViFPCRBvutGYwgHVfgTHOg== 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=1717407640; x=1717494040; bh=s9f8F7zj9a5hMGScmVLaK5hp+BJI 0KqfRM/mH7GW+Bs=; b=iWZkEmGqE0FfhOdsujE9kRSVBlwE8Xw6cHjfjdYrOk6y 9qY5j23TiEjqY0f93M2dTSeiW3BttYHPQMMqzZl+z61JGBP6SLT4AIVkWG0fgnmA XxMRm2q8WeGuu5YPe0n42y1xq3fTOShgkaYSLmmmOp/yd3j6wF012EU5VTSHJRQ2 EpQrpW6L5JmfxaiAtcJrk1itS/KgfTUb/EdhmwqC+U8q2xrE1WyRDGp29t8lv8y7 a6zlrC28ca5Oa0HwO4r2t7qQAVyc70IsXoD6bJJOKTcYW+a4KecRnw29Xkp9HDEG /YmGDc2NThGQt744KIRo8XAapMQQeKxAnQiUbHfUnQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelvddgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpeefnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Jun 2024 05:40:39 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id f6bcb001 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Jun 2024 09:40:15 +0000 (UTC) Date: Mon, 3 Jun 2024 11:40:37 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v3 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",