diff options
author | Sami Mujawar <sami.mujawar@arm.com> | 2020-10-22 09:42:51 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-12-22 01:26:10 +0000 |
commit | b23c5b9722b50d598f861c057122e91fa3e6b3fe (patch) | |
tree | 4919d755fe74ec595563807be664a1a87cef3370 /BaseTools/Source | |
parent | 35ed29f207fd9c3683cfee5492c5c4e96ee0a0eb (diff) | |
download | edk2-b23c5b9722b50d598f861c057122e91fa3e6b3fe.tar.gz edk2-b23c5b9722b50d598f861c057122e91fa3e6b3fe.tar.bz2 edk2-b23c5b9722b50d598f861c057122e91fa3e6b3fe.zip |
BaseTools: Fix crash in ECC when parsing incorrect header
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 <sami.mujawar@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'BaseTools/Source')
-rw-r--r-- | BaseTools/Source/Python/Ecc/c.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py index a30122a45f..db686df0db 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.<BR>
+# Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
# 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
|