diff --git a/0029-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch b/0029-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch new file mode 100644 index 0000000000000000000000000000000000000000..a643451ad98757dcc9e16799627cc3de5662ec28 --- /dev/null +++ b/0029-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch @@ -0,0 +1,51 @@ +From 5df044496a30e4fa62b71513f3ae87400ceff4c4 Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Wed, 12 Aug 2020 01:28:17 +0800 +Subject: [PATCH] BaseTools: fix ucs-2 lookup on python 3.9 + +python3.9 changed/fixed codec.register behavior to always replace +hyphen with underscore for passed in codec names: + + https://bugs.python.org/issue37751 + +So the custom Ucs2Search needs to be adapted to handle 'ucs_2' in +addition to existing 'ucs-2' for back compat. + +This fixes test failures on python3.9, example: + +====================================================================== +FAIL: testUtf16InUniFile (CheckUnicodeSourceFiles.Tests) +---------------------------------------------------------------------- +Traceback (most recent call last): + File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 375, in PreProcess + FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path)) + File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 303, in OpenUniFile + UniFileClassObject.VerifyUcs2Data(FileIn, FileName, Encoding) + File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 312, in VerifyUcs2Data + Ucs2Info = codecs.lookup('ucs-2') +LookupError: unknown encoding: ucs-2 + +Signed-off-by: Cole Robinson +Reviewed-by: Yuwei Chen +Reviewed-by: Bob Feng +Signed-off-by: Jinhua Cao +--- + BaseTools/Source/Python/AutoGen/UniClassObject.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py +index b2895f7e5c..883c2356e0 100644 +--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py ++++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py +@@ -152,7 +152,7 @@ class Ucs2Codec(codecs.Codec): + + TheUcs2Codec = Ucs2Codec() + def Ucs2Search(name): +- if name == 'ucs-2': ++ if name in ['ucs-2', 'ucs_2']: + return codecs.CodecInfo( + name=name, + encode=TheUcs2Codec.encode, +-- +2.27.0 + diff --git a/0030-BaseTools-Work-around-array.array.tostring-removal-i.patch b/0030-BaseTools-Work-around-array.array.tostring-removal-i.patch new file mode 100644 index 0000000000000000000000000000000000000000..aaff9cf24e72b8a5175853ded8aaf8831f9fdf1f --- /dev/null +++ b/0030-BaseTools-Work-around-array.array.tostring-removal-i.patch @@ -0,0 +1,51 @@ +From d935684f89d972f3b9ff8fabe18fffefe75b2ed6 Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Wed, 12 Aug 2020 01:28:18 +0800 +Subject: [PATCH] BaseTools: Work around array.array.tostring() removal in + python 3.9 + +In python3, array.array.tostring() was a compat alias for tobytes(). +tostring() was removed in python 3.9. + +Convert this to use tolist() which should be valid for all python +versions. + +This fixes this build error on python3.9: + +(Python 3.9.0b5 on linux) Traceback (most recent call last): + File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Trim.py", line 593, in Main + GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile) + File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Trim.py", line 449, in GenerateVfrBinSec + VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrNameList) + File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 88, in GetVariableOffset + return _parseForGCC(lines, efifilepath, varnames) + File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 151, in _parseForGCC + efisecs = PeImageClass(efifilepath).SectionHeaderList + File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 1638, in __init__ + if ByteArray.tostring() != b'PE\0\0': +AttributeError: 'array.array' object has no attribute 'tostring' + +Signed-off-by: Cole Robinson +Reviewed-by: Yuwei Chen +Reviewed-by: Bob Feng +Signed-off-by: Jinhua Cao +--- + BaseTools/Source/Python/Common/Misc.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py +index da5fb380f0..751b2c24f0 100755 +--- a/BaseTools/Source/Python/Common/Misc.py ++++ b/BaseTools/Source/Python/Common/Misc.py +@@ -1635,7 +1635,7 @@ class PeImageClass(): + ByteArray = array.array('B') + ByteArray.fromfile(PeObject, 4) + # PE signature should be 'PE\0\0' +- if ByteArray.tostring() != b'PE\0\0': ++ if ByteArray.tolist() != [ord('P'), ord('E'), 0, 0]: + self.ErrorInfo = self.FileName + ' has no valid PE signature PE00' + return + +-- +2.27.0 + diff --git a/edk2.spec b/edk2.spec index 815c96126c05da47292dbc66a753772f8dc48bba..30110864ddb6a6e06f86d094bebb6b11f564263d 100644 --- a/edk2.spec +++ b/edk2.spec @@ -5,7 +5,7 @@ Name: edk2 Version: %{stable_date} -Release: 10 +Release: 11 Summary: EFI Development Kit II License: BSD-2-Clause-Patent URL: https://github.com/tianocore/edk2 @@ -40,6 +40,8 @@ Patch0025: 0025-NetworkPkg-IScsiDxe-fix-IScsiHexToBin-hex-parsing.patch Patch0026: 0026-NetworkPkg-IScsiDxe-fix-IScsiHexToBin-buffer-overflo.patch Patch0027: 0027-NetworkPkg-IScsiDxe-check-IScsiHexToBin-return-value.patch Patch0028: 0028-MdeModulePkg-FPDT-Lock-boot-performance-table-addres.patch +Patch0029: 0029-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch +Patch0030: 0030-BaseTools-Work-around-array.array.tostring-removal-i.patch BuildRequires: acpica-tools gcc gcc-c++ libuuid-devel python3 bc nasm python3-unversioned-command @@ -237,6 +239,10 @@ chmod +x %{buildroot}%{_bindir}/Rsa2048Sha256GenerateKeys %endif %changelog +* Wed Jan 12 2022 Jinhua Cao - 202002-11 +- BaseTools: fix ucs-2 lookup on python3.9 +- BaseTools: Work around array.array.tostring() removal in python3.9 + * Wed Dec 1 2021 Jinhua Cao -202002-10 - fix CVE-2021-28216