X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=SecurityPkg%2FVariableAuthenticated%2FSecureBootConfigDxe%2FSecureBootConfigFileExplorer.c;h=2a26c20f394c0c162d52a76f650616a26d17f292;hp=1b6f88804275dc48886e710d7e01d4be9b59ff41;hb=79b10d4ce4f08aab4b9548fabc4542ca78a96247;hpb=bac308be0c48624334f15c8677069e0596bd00d1 diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c index 1b6f888042..2a26c20f39 100644 --- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c +++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c @@ -123,6 +123,8 @@ OpenFileByDevicePath( EFI_FILE_PROTOCOL *Handle1; EFI_FILE_PROTOCOL *Handle2; EFI_HANDLE DeviceHandle; + CHAR16 *PathName; + UINTN PathLength; if ((FilePath == NULL || FileHandle == NULL)) { return EFI_INVALID_PARAMETER; @@ -173,6 +175,11 @@ OpenFileByDevicePath( // Handle2 = Handle1; Handle1 = NULL; + PathLength = DevicePathNodeLength (*FilePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL); + PathName = AllocateCopyPool (PathLength, ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName); + if (PathName == NULL) { + return EFI_OUT_OF_RESOURCES; + } // // Try to test opening an existing file @@ -180,7 +187,7 @@ OpenFileByDevicePath( Status = Handle2->Open ( Handle2, &Handle1, - ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName, + PathName, OpenMode &~EFI_FILE_MODE_CREATE, 0 ); @@ -192,7 +199,7 @@ OpenFileByDevicePath( Status = Handle2->Open ( Handle2, &Handle1, - ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName, + PathName, OpenMode, Attributes ); @@ -202,6 +209,8 @@ OpenFileByDevicePath( // Handle2->Close (Handle2); + FreePool (PathName); + if (EFI_ERROR(Status)) { return (Status); }