From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.11536.1608138321960796508 for ; Wed, 16 Dec 2020 09:05:22 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9DBAFD6E; Wed, 16 Dec 2020 09:05:21 -0800 (PST) Received: from e120189.arm.com (unknown [10.57.25.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2F5143F66E; Wed, 16 Dec 2020 09:05:19 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io, bob.c.feng@intel.com, gaoliming@byosoft.com.cn, yuwei.chen@intel.com Cc: sami.mujawar@arm.com Subject: [PATCH v1 1/2] BaseTools: Fix crash in ECC when parsing incorrect header Date: Wed, 16 Dec 2020 17:05:05 +0000 Message-Id: <20201216170506.13313-2-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201216170506.13313-1-Pierre.Gondois@arm.com> References: <20201216170506.13313-1-Pierre.Gondois@arm.com> From: Sami Mujawar The ECC tool crashes if a C file has an incorrect file header format. The file ArmPkg\Library\ArmMmuLib\AArch64\ArmMmuPeiLibConstructor.c has a file header in the incorrect format. It uses # to mark the header comments instead of enclosing the file header in /* */. This may have been a result of an INF file header being copied to a C file. A separate patch fixes the C file but ECC tool should not crash if a file with an incorrect header is found. Therefore, update the ECC tool to prevent it from crashing if an incorrect file header is found. With this change the ECC tool will report the incorrect header issue without crashing. Signed-off-by: Sami Mujawar --- The changes can be seen at: https://github.com/PierreARM/edk2/commits/1551_Ecc_BaseTools_v1 BaseTools/Source/Python/Ecc/c.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py index a30122a45f81..db686df0db25 100644 --- a/BaseTools/Source/Python/Ecc/c.py +++ b/BaseTools/Source/Python/Ecc/c.py @@ -2,6 +2,7 @@ # This file is used to be the c coding style checking of ECC tool # # Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2020, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -64,7 +65,9 @@ def GetIdType(Str): Type = DataClass.MODEL_UNKNOWN Str = Str.replace('#', '# ') List = Str.split() - if List[1] == 'include': + if len(List) < 2: + pass + elif List[1] == 'include': Type = DataClass.MODEL_IDENTIFIER_INCLUDE elif List[1] == 'define': Type = DataClass.MODEL_IDENTIFIER_MACRO_DEFINE -- 2.17.1