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

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