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

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