From patchwork Tue Feb 12 01:22:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10807167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C5CA13A4 for ; Tue, 12 Feb 2019 01:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E6852AC67 for ; Tue, 12 Feb 2019 01:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32A5E2AC84; Tue, 12 Feb 2019 01:23:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5FDD2AC67 for ; Tue, 12 Feb 2019 01:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727324AbfBLBXw (ORCPT ); Mon, 11 Feb 2019 20:23:52 -0500 Received: from injection.crustytoothpaste.net ([192.241.140.119]:34352 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbfBLBXq (ORCPT ); Mon, 11 Feb 2019 20:23:46 -0500 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:3dc7:72ec:75fa:fee5]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 4857360E60; Tue, 12 Feb 2019 01:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1549934625; bh=SW5OJPhBLpqJ3hRLr4aeX6PSfsTg2E9HV5uvCFjbuCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=eiH3pM71TET9eGOkBMO5T6AEQ/AzOAfmhfiquoI8Mh0IMbsGVpVTXyU7RCuI0ubbz dgdXvFF+pMexBLNW2pFJNZOPyXPHOp+To19z9CbN6JHlECTRTrJIher84ItYUSLBGr v2FZXN53/4+KO3cU2mwJaYd4YMUUmnUsVMw0guKUU6PrEzIBJVISRfEMsvzhzalrNE HqiL6yWKW5b2qTbb4EN1aJN/bdaMCREWZlpVEhwQmPDpqREPa3Dc9q57HPdQIgPn9T TnpT08lEjrINYofLjzApH/sl8JGOciwHtHzOr1uT1KDlSRSJtfvQFeetTqqOg9nswe o5V8ovLqVUyQWJfKCtx0KOBFFZcsrQzKb/5VuNa5SDD1jqlXyhpBGMgtRGcoIA0YJ6 xLDvRXvarFNROYfwCFp/tKbI0DEmp1eooye4E71G7xd9/5Dl2pTGGd0NaESag1o+Sh fdncF9w6OV9Sg+NLHWX5n2UgtnXPmaCJ7HBCa9uOLEN/DLBHz9d From: "brian m. carlson" To: Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Duy Nguyen Subject: [PATCH 30/31] Git.pm: make hash size independent Date: Tue, 12 Feb 2019 01:22:55 +0000 Message-Id: <20190212012256.1005924-31-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.20.1.791.gb4d0f1c61a In-Reply-To: <20190212012256.1005924-1-sandals@crustytoothpaste.net> References: <20190212012256.1005924-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The cat_blob function was matching on exactly 40 hex characters. This won't work with SHA-256, which uses 64-character hex object IDs. While it should be fine to simply match any number of hex characters since the output is space delimited, be extra safe by matching either exactly 40 or exactly 64 hex characters. Signed-off-by: brian m. carlson --- perl/Git.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl/Git.pm b/perl/Git.pm index d856930b2e..62c472e0ce 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -980,7 +980,7 @@ sub cat_blob { return -1; } - if ($description !~ /^[0-9a-fA-F]{40} \S+ (\d+)$/) { + if ($description !~ /^[0-9a-fA-F]{40}(?:[0-9a-fA-F]{24})? \S+ (\d+)$/) { carp "Unexpected result returned from git cat-file"; return -1; }