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

39700a
From 29c96f00677e1dd2a9df4de645a7f5fab7b736a1 Mon Sep 17 00:00:00 2001
39700a
From: Vladimir Serbinenko <phcoder@gmail.com>
39700a
Date: Sat, 18 Jan 2014 16:41:47 +0100
39700a
Subject: [PATCH 020/143] 	* grub-core/kern/efi/efi.c: Ensure that the
39700a
 result starts with / 	and has no //.
39700a
39700a
---
39700a
 ChangeLog                |  5 +++++
39700a
 grub-core/kern/efi/efi.c | 25 +++++++++++++++++--------
39700a
 2 files changed, 22 insertions(+), 8 deletions(-)
39700a
39700a
diff --git a/ChangeLog b/ChangeLog
39700a
index 6a19f85..b04a4ef 100644
39700a
--- a/ChangeLog
39700a
+++ b/ChangeLog
39700a
@@ -1,5 +1,10 @@
39700a
 2014-01-18  Vladimir Serbinenko  <phcoder@gmail.com>
39700a
 
39700a
+	* grub-core/kern/efi/efi.c: Ensure that the result starts with /
39700a
+	and has no //.
39700a
+
39700a
+2014-01-18  Vladimir Serbinenko  <phcoder@gmail.com>
39700a
+
39700a
 	* NEWS: Add few missing entries.
39700a
 
39700a
 2014-01-17  Colin Watson  <cjwatson@ubuntu.com>
39700a
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
39700a
index b253141..b9eb1ab 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
 }
39700a
-- 
39700a
1.9.3
39700a