diff options
| author | Gary Ching-Pang Lin <glin@suse.com> | 2013-02-21 17:49:29 +0800 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2013-09-26 11:58:01 -0400 |
| commit | ca22da9defd7479b8e1ab045251a9b91c6af3a88 (patch) | |
| tree | 233ce4dff5a83c04fd97488e0fddb3e8a443390a | |
| parent | be9108a8b9c0433ad1f7a94fd5f8b1a92f4281d0 (diff) | |
| download | efi-boot-shim-ca22da9defd7479b8e1ab045251a9b91c6af3a88.tar.gz efi-boot-shim-ca22da9defd7479b8e1ab045251a9b91c6af3a88.zip | |
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>
| -rw-r--r-- | shim.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -995,15 +995,25 @@ static EFI_STATUS generate_path(EFI_LOADED_IMAGE *li, CHAR16 *ImagePath, 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)); @@ -1021,6 +1031,8 @@ static EFI_STATUS generate_path(EFI_LOADED_IMAGE *li, CHAR16 *ImagePath, *grubpath = FileDevicePath(device, *PathName); error: + FreePool(bootpath); + return efi_status; } |
