From 592bf33a29360e8a447ed8b75daefe94c0888642 Mon Sep 17 00:00:00 2001 From: Michael D Kinney Date: Fri, 9 Dec 2022 07:53:21 -0800 Subject: ShellPkg/Shell: Do not set end device path if already end 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 operation 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 Reviewed-by: Ard Biesheuvel Reviewed-by: Zhichao Gao --- ShellPkg/Application/Shell/ShellProtocol.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 509eb60e40..e6d20ab164 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); + } } /* -- cgit v1.2.3