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