From patchwork Thu Jun 6 10:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13688256 Received: from fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) (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 4589E14E2C4 for ; Thu, 6 Jun 2024 10:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717669768; cv=none; b=pteiCASE01/DXzlQtwPuamWqz6hLhtNrnOeI9aYHtUGA5FW7xbDxck6bx+pAeur7vN5Hl9pDZYUZztTgQorW3k8tS2QH+k5AleVdjHVmDdSkweJ6NG/uCyQLknfX5lOxKfXwVxX7qVyUG7IEGe1wjk5mf+89e4A0NnbZJ5FTAC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717669768; c=relaxed/simple; bh=b0oUX+ETLnnUrPk+a/V/rilDXyb8gWoehVOpE46kM6M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ImVcBquyzvfBEl5CSPLN5FWsCK+R8oN2LfS8JmivhYp2MlVnWv9I9qcYIbYXR9j646QlTDQzGy1vtqY4XIoVANLZWb/KZozCgPTi7Hr/YoMs44kMcCFxUabgPYZDrquf65dS5uUs1l4JYThVLteL2Y2+me0zbEtP7OhYUsalZXo= 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=F7hrHgEn; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VRMBVe95; arc=none smtp.client-ip=103.168.172.148 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="F7hrHgEn"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VRMBVe95" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id 62F011380149; Thu, 6 Jun 2024 06:29:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 06 Jun 2024 06:29:26 -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=1717669766; x=1717756166; bh=45c1C9cpal eCE/wUHN3r/f3HWkVEBuBeZ8AL6X9Z0Hw=; b=F7hrHgEnWnLhsJ7J3xuwwk3SFd U99wJT8+4mrVRGph26wKMPN4dz/6BHku4nzyvoRmJ/5qYFnCRhazb06ChOAm4SQi OfK171jf+N8+Z9YAUtsY8SiNI5qj44Fw3mNmcfKWjtSUazbpX98uH6jYoT+2+Byi 0VglE1eW/Vc8MEKFILrZU3cJlzOdJVr1DIKkgwKpPu+1OnhLBtccSSguIKS43/sy 6kyp4DYzJh/CSs5j9Nzu5l+p2ZvSQFZFgKYJ73Rmtly3UBNuQ9o302Yw7HI5pEKq zOJwv1R+0RJKCdX6rXpyVm/q+Kt2SpKTm9dPmljG47ReEdIQDE2RgQbkyW5g== 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=1717669766; x=1717756166; bh=45c1C9cpaleCE/wUHN3r/f3HWkVE BuBeZ8AL6X9Z0Hw=; b=VRMBVe95kCdE8KRU+hGvzYltyAndnPxNKCOb/utkMqtp OdYw1KG3WJu2hpP1pIeahI9Os0GBRvboEOVtesWbqtUldgWWeyhYJMhRfpvvxvVq GhSCuvFMiN8dVkRW4NWsqBrzuswqpB2HTO0Rayr6bJf55HnyrNXfJbKgLX/KhXek EQW+Q0sDt1ks6n+rzJxoV9HHS9ayYoF91IRO8sQW3ExX9p4d54TZanxOekBpIvnS BR+AhX39RhAfIIG9PG1l6MjbWskjGHjY2QRBErKqfkg2eccMVC0DKvrukL7gNDyL vWlkk2DSai5pM/EPVO5yh6FlLcDuAsuQf6fOChXD+g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelkedgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Jun 2024 06:29:25 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 0d042a11 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 6 Jun 2024 10:28:55 +0000 (UTC) Date: Thu, 6 Jun 2024 12:29:23 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Eric Sunshine Subject: [PATCH v5 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",