From patchwork Wed May 29 12:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13678801 Received: from wfout4-smtp.messagingengine.com (wfout4-smtp.messagingengine.com [64.147.123.147]) (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 0453D4C70 for ; Wed, 29 May 2024 12:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716986715; cv=none; b=k2MG7Uz9DcKMDo6jI5RU/zatwbkscox6/ojaW/+jah7NK7I2brm2mkBS1ohyP2EqhKmpABuDXjGDFer3eu/a4ksApOCAq5W/vTqXgBLVbST68HlqqK6ucPXP3WUP0wJz24UtpYs8DVtZSX01GPIDIZ0nD7bu4qs4To6E3eO6XpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716986715; c=relaxed/simple; bh=mooNOdW8hzdm+jm2Z2ntufcUxqvWvPYR/7mSwjnKfP8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Yu7Lt5kMLsnj1QRyw+bPgkRRpKcY8EYQ64ZKN84hxzNZm3AtQzNpFNWZHZDlucRlap8nkHK88btYny2hXh4Rhr3OFve84Tc5GmbIJZAslxwRXBjL1Va5Qr+y5/AZWsdApBrK69XdIuA0lm1porGlPfSYkI0A/qzesjtU+PavhsI= 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=iss3F0qV; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=XjkZYcpF; arc=none smtp.client-ip=64.147.123.147 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="iss3F0qV"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XjkZYcpF" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.west.internal (Postfix) with ESMTP id 55C031C000BF; Wed, 29 May 2024 08:45:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 29 May 2024 08:45:13 -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=1716986712; x=1717073112; bh=Ur8bXUargy EXX3WA/QlCkr1k6V29ZzNUiRdU2z6ZtRg=; b=iss3F0qVoCmhjO8Ql28tFyb7Mu MIdvsDupfLw56JmBvTrIskzCJnU3HDWMdJ3miOjQ4DjSjuYpP4V/hqY/xJ1u48Va KKvhgGNotaww7Sa2wkGQHbe9qy93yWxA0LRMDO0xC64BVHoZRdqJhiahBXzQyVld x2DAQYrbbjkRrquFRvxYnxFhRznxflQmh49T3mgfc42GExjECJDuvbZ+m519XYOT hY5m4K5nT8HQSE2Fq/Ffpy2CvGiduAVZcYKGBPgrFDvLuU7sJpt8YwPvCT7i7UAA Mf3MvTNy26pQBfLkpa4EVACGdhWzrCtr2LajyOJkmw49gQPMJYKg448Oih1w== 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=1716986712; x=1717073112; bh=Ur8bXUargyEXX3WA/QlCkr1k6V29 ZzNUiRdU2z6ZtRg=; b=XjkZYcpF2XaB8yJtO+e5HvvDYtKehgUK9j+NGVh6QAa/ 8OGpmJgb4cKLwOeum9pFerEPAh1tzBjJWY0nOcEsJyERgBmDyETlN38QxSFhQzHi +1F1ZNJeHsE6g8AZyhGOnanD/Ys20N9YRumnYQQqz+RWePjZa9tVsg7CERyZEAwn bIaxgkEthMQMPL91kWKEOrOPFLM6YhSO4gk4Pl6dnnrO7BbLiYck95mJCZOmFB5Z Wj3d7A90j1W4FhZMqkIDOLZ76ZHJHTDGPwEggxFp++V1T/f2QT/tNkpJZMOsgITn WTsJfM2hZ3PJegSIHl/mxnnGN3evgq+J12UnCFsVlQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdekuddgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 May 2024 08:45:11 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 3b8e7c06 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 29 May 2024 12:44:57 +0000 (UTC) Date: Wed, 29 May 2024 14:45:09 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King Subject: [PATCH 14/19] mailmap: always store allocated strings in mailmap blob Message-ID: <0e393fa6a708fc29fe666b75d89ed66cc69ec634.1716983704.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",