2013-07-23 04:44:22 +00:00
|
|
|
From bfffac234fabdf8110e8e8c53557d57d61320098 Mon Sep 17 00:00:00 2001
|
2013-02-22 10:31:48 +00:00
|
|
|
From: Gary Ching-Pang Lin <glin@suse.com>
|
|
|
|
Date: Thu, 21 Feb 2013 17:49:29 +0800
|
|
|
|
Subject: [PATCH] Fix the broken bootpath
|
|
|
|
|
|
|
|
- The file path from DevicePathToStr may use slash as the file
|
|
|
|
seperator. Change all slashes to backslashes to avoid the strange
|
|
|
|
bootpath.
|
|
|
|
- Remove the redundant backslashes.
|
|
|
|
- ImagePath no longer requires the leading backslash.
|
|
|
|
- Fix a memory leak
|
|
|
|
|
|
|
|
Based on the patch from Michal Marek <mmarek@suse.com>
|
|
|
|
---
|
2013-07-23 04:44:22 +00:00
|
|
|
shim.c | 22 +++++++++++++++++-----
|
2013-02-22 10:31:48 +00:00
|
|
|
1 file changed, 17 insertions(+), 5 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/shim.c b/shim.c
|
2013-07-23 04:44:22 +00:00
|
|
|
index 94b9710..0622c72 100644
|
2013-02-22 10:31:48 +00:00
|
|
|
--- a/shim.c
|
|
|
|
+++ b/shim.c
|
2013-07-23 04:44:22 +00:00
|
|
|
@@ -981,15 +981,25 @@ static EFI_STATUS generate_path(EFI_LOADED_IMAGE *li, CHAR16 *ImagePath,
|
2013-02-22 10:31:48 +00:00
|
|
|
|
|
|
|
pathlen = StrLen(bootpath);
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * DevicePathToStr() concatenates two nodes with '/'.
|
|
|
|
+ * Convert '/' to '\\'.
|
|
|
|
+ */
|
|
|
|
+ for (i = 0; i < pathlen; i++) {
|
|
|
|
+ if (bootpath[i] == '/')
|
|
|
|
+ bootpath[i] = '\\';
|
|
|
|
+ }
|
|
|
|
for (i=pathlen; i>0; i--) {
|
|
|
|
- if (bootpath[i] == '\\')
|
|
|
|
+ if (bootpath[i] == '\\' && bootpath[i-1] != '\\')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
+ if (bootpath[i] == '\\')
|
|
|
|
+ bootpath[i+1] = '\0';
|
|
|
|
+ else
|
|
|
|
+ bootpath[0] = '\0';
|
|
|
|
|
|
|
|
- bootpath[i+1] = '\0';
|
|
|
|
-
|
|
|
|
- if (i == 0 || bootpath[i-i] == '\\')
|
|
|
|
- bootpath[i] = '\0';
|
|
|
|
+ while (*ImagePath == '\\')
|
|
|
|
+ ImagePath++;
|
|
|
|
|
|
|
|
*PathName = AllocatePool(StrSize(bootpath) + StrSize(ImagePath));
|
|
|
|
|
2013-07-23 04:44:22 +00:00
|
|
|
@@ -1007,6 +1017,8 @@ static EFI_STATUS generate_path(EFI_LOADED_IMAGE *li, CHAR16 *ImagePath,
|
2013-02-22 10:31:48 +00:00
|
|
|
*grubpath = FileDevicePath(device, *PathName);
|
|
|
|
|
|
|
|
error:
|
|
|
|
+ FreePool(bootpath);
|
|
|
|
+
|
|
|
|
return efi_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2013-07-23 04:44:22 +00:00
|
|
|
1.8.1.4
|
2013-02-22 10:31:48 +00:00
|
|
|
|