dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0020-grub-core-kern-efi-efi.c-Ensure-that-the-result-star.patch

f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: Vladimir Serbinenko <phcoder@gmail.com>
f725e3
Date: Sat, 18 Jan 2014 16:41:47 +0100
f725e3
Subject: [PATCH] * grub-core/kern/efi/efi.c: Ensure that the result starts
f725e3
 with / and has no //.
f725e3
f725e3
---
f725e3
 grub-core/kern/efi/efi.c | 25 +++++++++++++++++--------
f725e3
 ChangeLog                |  5 +++++
f725e3
 2 files changed, 22 insertions(+), 8 deletions(-)
f725e3
f725e3
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
f725e3
index b253141f26e..b9eb1ab1e33 100644
f725e3
--- a/grub-core/kern/efi/efi.c
f725e3
+++ b/grub-core/kern/efi/efi.c
f725e3
@@ -309,7 +309,7 @@ grub_efi_modules_addr (void)
f725e3
 char *
f725e3
 grub_efi_get_filename (grub_efi_device_path_t *dp0)
f725e3
 {
f725e3
-  char *name = 0, *p;
f725e3
+  char *name = 0, *p, *pi;
f725e3
   grub_size_t filesize = 0;
f725e3
   grub_efi_device_path_t *dp;
f725e3
 
f725e3
@@ -328,7 +328,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
f725e3
 	  grub_efi_uint16_t len;
f725e3
 	  len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
f725e3
 		 / sizeof (grub_efi_char16_t));
f725e3
-	  filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 1;
f725e3
+	  filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 2;
f725e3
 	}
f725e3
 
f725e3
       dp = GRUB_EFI_NEXT_DEVICE_PATH (dp);
f725e3
@@ -356,12 +356,12 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
f725e3
 	  grub_efi_file_path_device_path_t *fp;
f725e3
 	  grub_efi_uint16_t len;
f725e3
 
f725e3
-	  if (p != name)
f725e3
-	    *p++ = '/';
f725e3
+	  *p++ = '/';
f725e3
 
f725e3
 	  len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
f725e3
 		 / sizeof (grub_efi_char16_t));
f725e3
 	  fp = (grub_efi_file_path_device_path_t *) dp;
f725e3
+
f725e3
 	  p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len);
f725e3
 	}
f725e3
 
f725e3
@@ -370,10 +370,19 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
f725e3
 
f725e3
   *p = '\0';
f725e3
 
f725e3
-  /* EFI breaks paths with backslashes.  */
f725e3
-  for (p = name; *p; p++)
f725e3
-    if (*p == '\\')
f725e3
-      *p = '/';
f725e3
+  for (pi = name, p = name; *pi;)
f725e3
+    {
f725e3
+      /* EFI breaks paths with backslashes.  */
f725e3
+      if (*pi == '\\' || *pi == '/')
f725e3
+	{
f725e3
+	  *p++ = '/';
f725e3
+	  while (*pi == '\\' || *pi == '/')
f725e3
+	    pi++;
f725e3
+	  continue;
f725e3
+	}
f725e3
+      *p++ = *pi++;
f725e3
+    }
f725e3
+  *p = '\0';
f725e3
 
f725e3
   return name;
f725e3
 }
f725e3
diff --git a/ChangeLog b/ChangeLog
f725e3
index 6a19f850448..b04a4ef70b9 100644
f725e3
--- a/ChangeLog
f725e3
+++ b/ChangeLog
f725e3
@@ -1,3 +1,8 @@
f725e3
+2014-01-18  Vladimir Serbinenko  <phcoder@gmail.com>
f725e3
+
f725e3
+	* grub-core/kern/efi/efi.c: Ensure that the result starts with /
f725e3
+	and has no //.
f725e3
+
f725e3
 2014-01-18  Vladimir Serbinenko  <phcoder@gmail.com>
f725e3
 
f725e3
 	* NEWS: Add few missing entries.