From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.5171.1670601608002227812 for ; Fri, 09 Dec 2022 08:00:08 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=JXexD/ND; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: michael.d.kinney@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670601608; x=1702137608; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+vPyxR1csBuJNCTq9BW9RPyia1Lka4Snx4Sw9368Phk=; b=JXexD/NDMv/WaUzJVnFw7ML02nCtuKLTOgTiaxsRdeuH+I/LO5a4IQx+ LwdlJ1IrvcWx1GtSlXFzX4p/Jr3AVzA3ClI4mEbCpFs73S4FCOIqH7yrW XFTXF4iers9HScLaAVICSw8VhvnF8mTCec2JQfUpeu3zvs/Lcoo2ZYFP3 iNWRvkjFD8P0LuD4S88IBUDlmB8uOT0QlZVLXsQGrtP0O8SxLJd7UK309 vLhE5IeS/o9mezuAHH0zQERfUJtuQTeHlS8/xFE0fTKZoB2LVbX7obGj6 hZH6neprE8qA9auiYpi+w9+vgjxj6BMlbz//1XG97qDIS0WeNjHvJrc5i g==; X-IronPort-AV: E=McAfee;i="6500,9779,10556"; a="300908586" X-IronPort-AV: E=Sophos;i="5.96,230,1665471600"; d="scan'208";a="300908586" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2022 07:59:50 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10556"; a="597765699" X-IronPort-AV: E=Sophos;i="5.96,230,1665471600"; d="scan'208";a="597765699" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.209.106.168]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2022 07:59:50 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Ray Ni , Zhichao Gao Subject: [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end Date: Fri, 9 Dec 2022 07:59:43 -0800 Message-Id: <20221209155943.367-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Update Shell Protocol EfiShellGetMapFromDevicePath() to not set the end if the device path if it is already an end of entire device path. This removes a write oprtation that can cause failures if the Device Path Protocol is mapped to read-only memory. In general Device Path Protocols should not be modified unless the API explicitly states that the device path is modified. Cc: Ard Biesheuvel Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Michael D Kinney --- ShellPkg/Application/Shell/ShellProtocol.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 509eb60e40f4..e6d20ab16479 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -294,7 +294,13 @@ EfiShellGetMapFromDevicePath ( *DevicePath = NextDevicePathNode (*DevicePath); } - SetDevicePathEndNode (*DevicePath); + // + // Do not call SetDevicePathEndNode() if the device path node is already the + // end of an entire device path. + // + if (!IsDevicePathEnd (*DevicePath)) { + SetDevicePathEndNode (*DevicePath); + } } /* -- 2.37.1.windows.1