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