From f843a328772a30c11162c281adaf2afc1b4a972f Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Fri, 3 Aug 2018 15:46:20 +0800 Subject: [PATCH] BaseTools: Add check for VOID* PCD Max Size Per spec VOID* PCD max size should be a UINT16 value. so this patch add the value check whether it is in range 0x0 .. 0xFFFF. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- .../Source/Python/Workspace/DscBuildData.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index e8b36a3868..c7f07f4646 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1536,6 +1536,13 @@ class DscBuildData(PlatformBuildClassObject): if Setting is None: continue PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) + if MaxDatumSize: + if int(MaxDatumSize, 0) > 0xFFFF: + EdkLogger.error('build', FORMAT_INVALID, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid, PcdCName)), + File=self.MetaFile, Line=Dummy4) + if int(MaxDatumSize, 0) < 0: + EdkLogger.error('build', FORMAT_INVALID, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdCName)), + File=self.MetaFile, Line=Dummy4) if (PcdCName, TokenSpaceGuid) in PcdValueDict: PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] = (PcdValue, DatumType, MaxDatumSize) else: @@ -2381,6 +2388,13 @@ class DscBuildData(PlatformBuildClassObject): continue PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) + if MaxDatumSize: + if int(MaxDatumSize, 0) > 0xFFFF: + EdkLogger.error('build', FORMAT_INVALID, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid, PcdCName)), + File=self.MetaFile, Line=Dummy4) + if int(MaxDatumSize, 0) < 0: + EdkLogger.error('build', FORMAT_INVALID, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdCName)), + File=self.MetaFile, Line=Dummy4) SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', '', PcdValue) if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject = Pcds[PcdCName, TokenSpaceGuid] @@ -2714,6 +2728,13 @@ class DscBuildData(PlatformBuildClassObject): # until the DEC parser has been called. # VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) + if MaxDatumSize: + if int(MaxDatumSize, 0) > 0xFFFF: + EdkLogger.error('build', FORMAT_INVALID, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid, PcdCName)), + File=self.MetaFile, Line=Dummy4) + if int(MaxDatumSize, 0) < 0: + EdkLogger.error('build', FORMAT_INVALID, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdCName)), + File=self.MetaFile, Line=Dummy4) SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', VpdOffset, InitialValue) if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject = Pcds[PcdCName, TokenSpaceGuid]