aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2012-12-12 16:07:41 +0000
committerJames Bottomley <JBottomley@Parallels.com>2012-12-12 16:25:09 +0000
commit64325e6ffdccb5591d9093474388a3164c8c31dc (patch)
treef4762915a763d90b209d757584202b7216aab0da
parent1ab89208fca8bb431a7681e87b63ceedca5cfec9 (diff)
downloadefitools-64325e6ffdccb5591d9093474388a3164c8c31dc.tar.gz
execute: fix some of the quirks in DevPathToStr()
Apparently it can use a forward slash '/' anywhere in the path name to indicate the split between the device the file is on and the rest of the name. Turn it back to a backslash '\' and make sure we don't have multiple ones at the end. Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--lib/execute.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/execute.c b/lib/execute.c
index 27b3d50..8d726eb 100644
--- a/lib/execute.c
+++ b/lib/execute.c
@@ -47,21 +47,23 @@
EFI_STATUS
generate_path(CHAR16* name, EFI_LOADED_IMAGE *li, EFI_DEVICE_PATH **path, CHAR16 **PathName)
{
- EFI_DEVICE_PATH *devpath;
unsigned int pathlen;
EFI_STATUS efi_status = EFI_SUCCESS;
CHAR16 *devpathstr = DevicePathToStr(li->FilePath),
*found = NULL;
int i;
- devpath = li->FilePath;
-
- for (i = 0; i < StrLen(devpathstr); i++)
+ for (i = 0; i < StrLen(devpathstr); i++) {
+ if (devpathstr[i] == '/')
+ devpathstr[i] = '\\';
if (devpathstr[i] == '\\')
found = &devpathstr[i];
+ }
if (!found) {
pathlen = 0;
} else {
+ while (*(found - 1) == '\\')
+ --found;
*found = '\0';
pathlen = StrLen(devpathstr);
}
@@ -78,8 +80,6 @@ generate_path(CHAR16* name, EFI_LOADED_IMAGE *li, EFI_DEVICE_PATH **path, CHAR16
}
StrCpy(*PathName, devpathstr);
- if ((*PathName)[StrLen(*PathName) - 1] == '/')
- (*PathName)[StrLen(*PathName) - 1] = '\0';
if (name[0] != '\\')
StrCat(*PathName, L"\\");
@@ -89,6 +89,7 @@ generate_path(CHAR16* name, EFI_LOADED_IMAGE *li, EFI_DEVICE_PATH **path, CHAR16
error:
FreePool(devpathstr);
+
return efi_status;
}