summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Ching-Pang Lin <glin@suse.com>2013-09-26 11:58:01 -0400
committerPeter Jones <pjones@redhat.com>2013-09-26 11:58:01 -0400
commit436afcc276d2400ac5fd65d4300047b266901d16 (patch)
tree843765880a4bb994ad99c0836ff51e1a0a067dda
parentf9f81a22dd8794850f58b27e984162b539de1344 (diff)
downloadefi-boot-shim-436afcc276d2400ac5fd65d4300047b266901d16.tar.gz
efi-boot-shim-436afcc276d2400ac5fd65d4300047b266901d16.zip
Remove double-separators from the bootpath
-rw-r--r--shim.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/shim.c b/shim.c
index 5c784066..9b1117f4 100644
--- a/shim.c
+++ b/shim.c
@@ -983,7 +983,7 @@ static EFI_STATUS generate_path(EFI_LOADED_IMAGE *li, CHAR16 *ImagePath,
{
EFI_DEVICE_PATH *devpath;
EFI_HANDLE device;
- int i;
+ int i, j, last = -1;
unsigned int pathlen = 0;
EFI_STATUS efi_status = EFI_SUCCESS;
CHAR16 *bootpath;
@@ -1003,14 +1003,27 @@ static EFI_STATUS generate_path(EFI_LOADED_IMAGE *li, CHAR16 *ImagePath,
if (bootpath[i] == '/')
bootpath[i] = '\\';
}
+
for (i=pathlen; i>0; i--) {
- if (bootpath[i] == '\\' && bootpath[i-1] != '\\')
- break;
+ if (bootpath[i] == '\\' && bootpath[i-1] == '\\')
+ bootpath[i] = '/';
+ else if (last == -1 && bootpath[i] == '\\')
+ last = i;
+ }
+
+ if (last == -1 && bootpath[0] == '\\')
+ last = 0;
+ bootpath[last+1] = '\0';
+
+ if (last > 0) {
+ for (i = 0, j = 0; bootpath[i] != '\0'; i++) {
+ if (bootpath[i] != '/') {
+ bootpath[j] = bootpath[i];
+ j++;
+ }
+ }
+ bootpath[j] = '\0';
}
- if (bootpath[i] == '\\')
- bootpath[i+1] = '\0';
- else
- bootpath[0] = '\0';
while (*ImagePath == '\\')
ImagePath++;