From nobody Fri May 3 11:46:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1533284103230443.6286135565829; Fri, 3 Aug 2018 01:15:03 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E002121A00AE6; Fri, 3 Aug 2018 01:15:01 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EDD6021BADAB2 for ; Fri, 3 Aug 2018 01:14:59 -0700 (PDT) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Aug 2018 01:14:58 -0700 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga008.jf.intel.com with ESMTP; 03 Aug 2018 01:14:57 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,437,1526367600"; d="scan'208";a="62069210" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Fri, 3 Aug 2018 16:14:55 +0800 Message-Id: <1533284095-16364-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [Patch] BaseTools: Add check for VOID* PCD Max Size X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RDMRC_1 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- BaseTools/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 e8b36a3..c7f07f4 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1534,10 +1534,17 @@ class DscBuildData(PlatformBuildClassObject): for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdSet: Setting =3D PcdDict[self._Arch, PcdCName, TokenSpaceGuid, SkuN= ame] if Setting is None: continue PcdValue, DatumType, MaxDatumSize =3D self._ValidatePcd(PcdCNa= me, TokenSpaceGuid, Setting, Type, Dummy4) + if MaxDatumSize: + if int(MaxDatumSize, 0) > 0xFFFF: + EdkLogger.error('build', FORMAT_INVALID, "The size val= ue must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join= ((TokenSpaceGuid, PcdCName)), + File=3Dself.MetaFile, Line=3DDummy4) + if int(MaxDatumSize, 0) < 0: + EdkLogger.error('build', FORMAT_INVALID, "The size val= ue can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdC= Name)), + File=3Dself.MetaFile, Line=3DDummy4) if (PcdCName, TokenSpaceGuid) in PcdValueDict: PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] =3D (PcdVa= lue, DatumType, MaxDatumSize) else: PcdValueDict[PcdCName, TokenSpaceGuid] =3D {SkuName:(PcdVa= lue, DatumType, MaxDatumSize)} =20 @@ -2379,10 +2386,17 @@ class DscBuildData(PlatformBuildClassObject): Setting =3D PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceG= uid] if Setting is None: continue =20 PcdValue, DatumType, MaxDatumSize =3D self._ValidatePcd(PcdCNa= me, TokenSpaceGuid, Setting, Type, Dummy4) + if MaxDatumSize: + if int(MaxDatumSize, 0) > 0xFFFF: + EdkLogger.error('build', FORMAT_INVALID, "The size val= ue must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join= ((TokenSpaceGuid, PcdCName)), + File=3Dself.MetaFile, Line=3DDummy4) + if int(MaxDatumSize, 0) < 0: + EdkLogger.error('build', FORMAT_INVALID, "The size val= ue can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdC= Name)), + File=3Dself.MetaFile, Line=3DDummy4) SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '',= '', '', '', '', PcdValue) if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject =3D Pcds[PcdCName, TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] =3D SkuInfo if MaxDatumSize.strip(): @@ -2712,10 +2726,17 @@ class DscBuildData(PlatformBuildClassObject): # For the Integer & Boolean type, the optional data can only b= e InitialValue. # At this point, we put all the data into the PcdClssObject fo= r we don't know the PCD's datumtype # until the DEC parser has been called. # VpdOffset, MaxDatumSize, InitialValue =3D self._ValidatePcd(Pc= dCName, TokenSpaceGuid, Setting, Type, Dummy4) + if MaxDatumSize: + if int(MaxDatumSize, 0) > 0xFFFF: + EdkLogger.error('build', FORMAT_INVALID, "The size val= ue must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join= ((TokenSpaceGuid, PcdCName)), + File=3Dself.MetaFile, Line=3DDummy4) + if int(MaxDatumSize, 0) < 0: + EdkLogger.error('build', FORMAT_INVALID, "The size val= ue can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdC= Name)), + File=3Dself.MetaFile, Line=3DDummy4) SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '',= '', '', '', VpdOffset, InitialValue) if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject =3D Pcds[PcdCName, TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] =3D SkuInfo if MaxDatumSize.strip(): --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel