summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2013-04-26 11:38:10 -0400
committerPeter Jones <pjones@redhat.com>2013-04-26 11:44:28 -0400
commit4df3d7c3efdb844ac534f7dac9f34338c1347263 (patch)
tree2a9994308561ca1e16328f4abd7a4cc5ee7191cd
parent2cead91ea22bd65a8560f41bcdaa0a8569f524fe (diff)
downloadefi-boot-shim-4df3d7c3efdb844ac534f7dac9f34338c1347263.tar.gz
efi-boot-shim-4df3d7c3efdb844ac534f7dac9f34338c1347263.zip
Don't put the directory in the file path twice.
Sometimes when we're creating paths, the ImagePath can contain the directory name already. If that happens, don't add it in again. Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--shim.c3
-rw-r--r--ucs2.h19
2 files changed, 21 insertions, 1 deletions
diff --git a/shim.c b/shim.c
index 32b3ae95..7abbe8b4 100644
--- a/shim.c
+++ b/shim.c
@@ -939,7 +939,8 @@ static EFI_STATUS generate_path(EFI_LOADED_IMAGE *li, CHAR16 *ImagePath,
}
*PathName[0] = '\0';
- StrCat(*PathName, bootpath);
+ if (StrnCaseCmp(bootpath, ImagePath, StrLen(bootpath)))
+ StrCat(*PathName, bootpath);
StrCat(*PathName, ImagePath);
*grubpath = FileDevicePath(device, *PathName);
diff --git a/ucs2.h b/ucs2.h
index 7c49b09b..03742847 100644
--- a/ucs2.h
+++ b/ucs2.h
@@ -54,4 +54,23 @@ StrCaseCmp(CHAR16 *s0, CHAR16 *s1)
return 0;
}
+static inline INTN
+__attribute__((unused))
+StrnCaseCmp(CHAR16 *s0, CHAR16 *s1, int n)
+{
+ CHAR16 c0, c1;
+ int x = 0;
+ while (n > x++) {
+ if (*s0 == L'\0' || *s1 == L'\0')
+ return *s1 - *s0;
+ c0 = (*s0 >= L'a' && *s0 <= L'z') ? *s0 - 32 : *s0;
+ c1 = (*s1 >= L'a' && *s1 <= L'z') ? *s1 - 32 : *s1;
+ if (c0 != c1)
+ return c1 - c0;
+ s0++;
+ s1++;
+ }
+ return 0;
+}
+
#endif /* SHIM_UCS2_H */