nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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