|
|
a85e8e |
From 34dbd541e7baea7391f11377d83db707568a8d91 Mon Sep 17 00:00:00 2001
|
|
|
a85e8e |
From: Lenny Szubowicz <lszubowi@redhat.com>
|
|
|
a85e8e |
Date: Mon, 29 Aug 2016 11:04:48 -0400
|
|
|
a85e8e |
Subject: [PATCH 212/260] Normalize slashes in tftp paths.
|
|
|
a85e8e |
|
|
|
a85e8e |
Some tftp servers do not handle multiple consecutive slashes correctly;
|
|
|
a85e8e |
this patch avoids sending tftp requests with non-normalized paths.
|
|
|
a85e8e |
|
|
|
a85e8e |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
a85e8e |
---
|
|
|
a85e8e |
grub-core/net/tftp.c | 28 +++++++++++++++++++++++++---
|
|
|
a85e8e |
1 file changed, 25 insertions(+), 3 deletions(-)
|
|
|
a85e8e |
|
|
|
a85e8e |
diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
|
|
|
a85e8e |
index 22a4debdc..8632339de 100644
|
|
|
a85e8e |
--- a/grub-core/net/tftp.c
|
|
|
a85e8e |
+++ b/grub-core/net/tftp.c
|
|
|
a85e8e |
@@ -300,6 +300,25 @@ destroy_pq (tftp_data_t data)
|
|
|
a85e8e |
grub_priority_queue_destroy (data->pq);
|
|
|
a85e8e |
}
|
|
|
a85e8e |
|
|
|
a85e8e |
+/* Create a normalized copy of the filename.
|
|
|
a85e8e |
+ Compress any string of consecutive forward slashes to a single forward
|
|
|
a85e8e |
+ slash. */
|
|
|
a85e8e |
+static void
|
|
|
a85e8e |
+grub_normalize_filename (char *normalized, const char *filename)
|
|
|
a85e8e |
+{
|
|
|
a85e8e |
+ char *dest = normalized;
|
|
|
a85e8e |
+ char *src = filename;
|
|
|
a85e8e |
+
|
|
|
a85e8e |
+ while (*src != '\0')
|
|
|
a85e8e |
+ {
|
|
|
a85e8e |
+ if (src[0] == '/' && src[1] == '/')
|
|
|
a85e8e |
+ src++;
|
|
|
a85e8e |
+ else
|
|
|
a85e8e |
+ *dest++ = *src++;
|
|
|
a85e8e |
+ }
|
|
|
a85e8e |
+ *dest = '\0';
|
|
|
a85e8e |
+}
|
|
|
a85e8e |
+
|
|
|
a85e8e |
static grub_err_t
|
|
|
a85e8e |
tftp_open (struct grub_file *file, const char *filename)
|
|
|
a85e8e |
{
|
|
|
a85e8e |
@@ -334,9 +353,12 @@ tftp_open (struct grub_file *file, const char *filename)
|
|
|
a85e8e |
rrqlen = 0;
|
|
|
a85e8e |
|
|
|
a85e8e |
tftph->opcode = grub_cpu_to_be16 (TFTP_RRQ);
|
|
|
a85e8e |
- grub_strcpy (rrq, filename);
|
|
|
a85e8e |
- rrqlen += grub_strlen (filename) + 1;
|
|
|
a85e8e |
- rrq += grub_strlen (filename) + 1;
|
|
|
a85e8e |
+
|
|
|
a85e8e |
+ /* Copy and normalize the filename to work-around issues on some tftp
|
|
|
a85e8e |
+ servers when file names are being matched for remapping. */
|
|
|
a85e8e |
+ grub_normalize_filename (rrq, filename);
|
|
|
a85e8e |
+ rrqlen += grub_strlen (rrq) + 1;
|
|
|
a85e8e |
+ rrq += grub_strlen (rrq) + 1;
|
|
|
a85e8e |
|
|
|
a85e8e |
grub_strcpy (rrq, "octet");
|
|
|
a85e8e |
rrqlen += grub_strlen ("octet") + 1;
|
|
|
a85e8e |
--
|
|
|
a85e8e |
2.13.0
|
|
|
a85e8e |
|