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

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