Blame SOURCES/0077-Normalize-slashes-in-tftp-paths.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Lenny Szubowicz <lszubowi@redhat.com>
8631a2
Date: Mon, 29 Aug 2016 11:04:48 -0400
8631a2
Subject: [PATCH] Normalize slashes in tftp paths.
8631a2
8631a2
Some tftp servers do not handle multiple consecutive slashes correctly;
8631a2
this patch avoids sending tftp requests with non-normalized paths.
8631a2
8631a2
Signed-off-by: Peter Jones <pjones@redhat.com>
8631a2
---
8631a2
 grub-core/net/tftp.c | 24 +++++++++++++++++++++++-
8631a2
 1 file changed, 23 insertions(+), 1 deletion(-)
8631a2
8631a2
diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
f6e916
index 1157524fc..5ca0a96a6 100644
8631a2
--- a/grub-core/net/tftp.c
8631a2
+++ b/grub-core/net/tftp.c
8631a2
@@ -300,6 +300,25 @@ destroy_pq (tftp_data_t data)
8631a2
   grub_priority_queue_destroy (data->pq);
8631a2
 }
8631a2
 
8631a2
+/* Create a normalized copy of the filename.
8631a2
+   Compress any string of consecutive forward slashes to a single forward
8631a2
+   slash. */
8631a2
+static void
8631a2
+grub_normalize_filename (char *normalized, const char *filename)
8631a2
+{
8631a2
+  char *dest = normalized;
8631a2
+  char *src = filename;
8631a2
+
8631a2
+  while (*src != '\0')
8631a2
+    {
8631a2
+      if (src[0] == '/' && src[1] == '/')
8631a2
+	src++;
8631a2
+      else
8631a2
+	*dest++ = *src++;
8631a2
+    }
8631a2
+  *dest = '\0';
8631a2
+}
8631a2
+
8631a2
 static grub_err_t
8631a2
 tftp_open (struct grub_file *file, const char *filename)
8631a2
 {
8631a2
@@ -337,7 +356,10 @@ tftp_open (struct grub_file *file, const char *filename)
8631a2
   rrqlen = 0;
8631a2
 
8631a2
   tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ);
8631a2
-  grub_strcpy (rrq, filename);
8631a2
+
8631a2
+  /* Copy and normalize the filename to work-around issues on some tftp
8631a2
+     servers when file names are being matched for remapping. */
8631a2
+  grub_normalize_filename (rrq, filename);
8631a2
   rrqlen += grub_strlen (filename) + 1;
8631a2
   rrq += grub_strlen (filename) + 1;
8631a2