From nobody Sat Apr 27 02:51:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72862+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72862+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1615887832; cv=none; d=zohomail.com; s=zohoarc; b=GfcJjwSCCxHgTNWxYJCV0fHhnSqYnKs2nHkOa56tk5Kpou4yoAKcAzdX3dpIFWXL4cR9BE3YOeq49i6k/bEYwMcLKQ4Qv3FBmqJumdQKZemr6NwkZJ7/nDXmL7D4lf6Q9LHxyqJaKE4XS+nH8UyN9z+YzoEvc9ndkxfFAbD6AdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615887832; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=ZAZGtcsMf8vhVwRjz18SrPvJ/2CIzybLZC5LfaA1Ip4=; b=RjI3IByh9UqMT2WVQSH4zKSe/drHGGp0BwfZJZ4jtzkMp6/jpRbtMM0OJtZQ8aRdr5jznrnbP31yJomkhTULiTryXTBmdbqH/fg1CEqxXRiPMUtz0GHUk06jZWzPuhC7kY6c9nXpWkBb/zCgTCI5tRM99ORSQfQ29JGJKpnoQb0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72862+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1615887831946894.726079651827; Tue, 16 Mar 2021 02:43:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id hU6jYY1788612x0iTyP9Pl1O; Tue, 16 Mar 2021 02:43:51 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web08.6082.1615887830929565525 for ; Tue, 16 Mar 2021 02:43:51 -0700 IronPort-SDR: I68uXuuhx7DfP+0/DKo1ZVnTyq1w2AXTfgXgqLKlf+mn2qhffu4f8kIkP2f5PUTgcjdXRHB0AE 0tUHb3kEc7Hw== X-IronPort-AV: E=McAfee;i="6000,8403,9924"; a="189280270" X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="189280270" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 02:43:49 -0700 IronPort-SDR: 3fRDfk+9tQ5jCvhBgbzP1xEpNJoZQMD1wI5Q6nGyUZwbZkMfcNyc2O2W6OPleBR2H3yr3OtHQG xBaoOU/7pqUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="378813550" X-Received: from ikuox-tiger-lake-client-platform.itwn.intel.com ([10.5.215.23]) by fmsmga007.fm.intel.com with ESMTP; 16 Mar 2021 02:43:48 -0700 From: "IanX Kuo" To: devel@edk2.groups.io Cc: VincentX Ke Subject: [edk2-devel] [PATCH] ShellPkg/Library: Fix bug in Pci.c Date: Sat, 10 Apr 2021 01:34:45 +0800 Message-Id: <19d74844dec841c0c8dda5d6426c67d609ec9d44.1615887240.git.vincentx.ke@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ianx.kuo@intel.com X-Gm-Message-State: VR3n8QuM8ZD2hOzpYTpxvJXnx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615887831; bh=WHPzmx9wae82/wz/2A7JsuMm2zaNR4Q07i34tiC2iMs=; h=Cc:Date:From:Reply-To:Subject:To; b=lAYbfVkaZ75ZmQI8kF9904ZXU9CtFQ4jpSSS26EsoUGnoTuz1AlYpG92VZN781fsk8S SvavYDdkbt9MHzMMYW0DCUo6xezlEwg9dHCLwGRAraCjaXu9kQKkmL2j4lWtAfHErGTQ9 xZU0247yJMjne7QR9HfAmQvZB921xM2/w3A= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: VincentX Ke Bugzilla: 3262 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3262) No need to print PCIe details while CapabilityId is 0xFFFF. Limit the NextCapabilityOffset value to AllocatePool() memory. Signed-off-by: VincentX Ke --- ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/L= ibrary/UefiShellDebug1CommandsLib/Pci.c index a2f04d8db5..9ebf1c26ef 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c @@ -2038,12 +2038,14 @@ LocatePciCapability ( =20 @param[in] PciExpressCap PCI Express capability buffer. @param[in] ExtendedConfigSpace PCI Express extended configuration space. + @param[in] ExtendedConfigSize PCI Express extended configuration size. @param[in] ExtendedCapability PCI Express extended capability ID to exp= lain. **/ VOID PciExplainPciExpress ( IN PCI_CAPABILITY_PCIEXP *PciExpressCap, IN UINT8 *ExtendedConfigSpace, + IN UINTN ExtendedConfigSize, IN CONST UINT16 ExtendedCapability ); =20 @@ -2921,6 +2923,7 @@ ShellCommandRunPci ( PciExplainPciExpress ( (PCI_CAPABILITY_PCIEXP *) ((UINT8 *) &ConfigSpace + PcieCapabili= tyPtr), ExtendedConfigSpace, + ExtendedConfigSize, ExtendedCapability ); } @@ -5698,12 +5701,14 @@ PrintPciExtendedCapabilityDetails( =20 @param[in] PciExpressCap PCI Express capability buffer. @param[in] ExtendedConfigSpace PCI Express extended configuration space. + @param[in] ExtendedConfigSize PCI Express extended configuration size. @param[in] ExtendedCapability PCI Express extended capability ID to exp= lain. **/ VOID PciExplainPciExpress ( IN PCI_CAPABILITY_PCIEXP *PciExpressCap, IN UINT8 *ExtendedConfigSpace, + IN UINTN ExtendedConfigSize, IN CONST UINT16 ExtendedCapability ) { @@ -5786,7 +5791,7 @@ PciExplainPciExpress ( } =20 ExtHdr =3D (PCI_EXP_EXT_HDR*)ExtendedConfigSpace; - while (ExtHdr->CapabilityId !=3D 0 && ExtHdr->CapabilityVersion !=3D 0) { + while (ExtHdr->CapabilityId !=3D 0 && ExtHdr->CapabilityVersion !=3D 0 &= & ExtHdr->CapabilityId !=3D 0xFFFF) { // // Process this item // @@ -5800,7 +5805,7 @@ PciExplainPciExpress ( // // Advance to the next item if it exists // - if (ExtHdr->NextCapabilityOffset !=3D 0) { + if (ExtHdr->NextCapabilityOffset !=3D 0 && (ExtHdr->NextCapabilityOffs= et <=3D (UINT32)(ExtendedConfigSize - sizeof (PCI_EXP_EXT_HDR)))) { ExtHdr =3D (PCI_EXP_EXT_HDR*)(ExtendedConfigSpace + ExtHdr->NextCapa= bilityOffset - EFI_PCIE_CAPABILITY_BASE_OFFSET); } else { break; --=20 2.18.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#72862): https://edk2.groups.io/g/devel/message/72862 Mute This Topic: https://groups.io/mt/81372175/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-