From 4f72d9c0decd813170702666e1fce11f9bd35516f500cb61755f02846f5ab541 Mon Sep 17 00:00:00 2001 From: Gary Ching-Pang Lin Date: Fri, 22 Feb 2013 10:31:48 +0000 Subject: [PATCH] Accepting request 156025 from home:gary_lin:branches:devel:openSUSE:Factory bnc#804631: fix the broken bootpath generated in generate_path() OBS-URL: https://build.opensuse.org/request/show/156025 OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory/shim?expand=0&rev=10 --- shim-bnc804631-fix-broken-bootpath.patch | 64 ++++++++++++++++++++++++ shim.changes | 6 +++ shim.spec | 3 ++ 3 files changed, 73 insertions(+) create mode 100644 shim-bnc804631-fix-broken-bootpath.patch diff --git a/shim-bnc804631-fix-broken-bootpath.patch b/shim-bnc804631-fix-broken-bootpath.patch new file mode 100644 index 0000000..32d63c9 --- /dev/null +++ b/shim-bnc804631-fix-broken-bootpath.patch @@ -0,0 +1,64 @@ +From 6b70850baa958b196ec332cf0224ffa9d5a81f5f Mon Sep 17 00:00:00 2001 +From: Gary Ching-Pang Lin +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 +--- + shim.c | 22 +++++++++++++++++----- + 1 file changed, 17 insertions(+), 5 deletions(-) + +diff --git a/shim.c b/shim.c +index 37a5898..690d064 100644 +--- a/shim.c ++++ b/shim.c +@@ -919,15 +919,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)); + +@@ -944,6 +954,8 @@ static EFI_STATUS generate_path(EFI_LOADED_IMAGE *li, CHAR16 *ImagePath, + *grubpath = FileDevicePath(device, *PathName); + + error: ++ FreePool(bootpath); ++ + return efi_status; + } + +-- +1.7.10.4 + diff --git a/shim.changes b/shim.changes index 224c6b5..3bb8e17 100644 --- a/shim.changes +++ b/shim.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Feb 21 10:08:12 UTC 2013 - glin@suse.com + +- Add shim-bnc804631-fix-broken-bootpath.patch to fix the broken + bootpath generated in generate_path(). (bnc#804631) + ------------------------------------------------------------------- Mon Feb 11 12:15:25 UTC 2013 - fcrozat@suse.com diff --git a/shim.spec b/shim.spec index 184a26f..dafc0c1 100644 --- a/shim.spec +++ b/shim.spec @@ -52,6 +52,8 @@ Patch8: shim-mokmanager-new-pw-hash.patch Patch9: shim-mokmanager-support-crypt-hash-method.patch # PATCH-FIX-OPENSUSE shim-keep-unsigned-mokmanager.patch glin@suse.com -- Keep MokManager.efi and sign it with the openSUSE key later Patch10: shim-keep-unsigned-mokmanager.patch +# PATCH-FIX-UPSTREAM shim-bnc804631-fix-broken-bootpath.patch bnc#804631 glin@suse.com -- Fix the broken bootpath generated in generate_path() +Patch11: shim-bnc804631-fix-broken-bootpath.patch BuildRequires: gnu-efi >= 3.0q BuildRequires: mozilla-nss-tools BuildRequires: openssl >= 0.9.8 @@ -83,6 +85,7 @@ Authors: %patch8 -p1 %patch9 -p1 %patch10 -p1 +%patch11 -p1 %build chmod +x "make-certs"