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