51 lines
1.5 KiB
Diff
51 lines
1.5 KiB
Diff
From 0bfc3978f4a6a10e4427fdab222b0e50c3c7283c Mon Sep 17 00:00:00 2001
|
|
From: Alberto Perez <aperezguevar@microsoft.com>
|
|
Date: Mon, 30 Jan 2023 14:52:15 -0600
|
|
Subject: [PATCH] Work around malformed path delimiters in file paths from DHCP
|
|
|
|
shim uses path delimiters to determine the file path for the second
|
|
stage. Currently only / (slash) is detected, but some DHCP
|
|
implementations supply \ (backslash) as the path specifier.
|
|
|
|
This patch changes it to accept either delimiter.
|
|
|
|
Fixes issue #524.
|
|
|
|
Signed-off-by: Alberto Perez <aperezguevar@microsoft.com>
|
|
---
|
|
netboot.c | 11 ++++++++++-
|
|
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/netboot.c b/netboot.c
|
|
index cf5882c..832deec 100644
|
|
--- a/netboot.c
|
|
+++ b/netboot.c
|
|
@@ -263,7 +263,7 @@ static EFI_STATUS parseDhcp4()
|
|
UINT8 *dir = pkt_v4->BootpBootFile;
|
|
|
|
for (i = dir_len; i >= 0; i--) {
|
|
- if (dir[i] == '/')
|
|
+ if ((dir[i] == '/') || (dir[i] == '\\'))
|
|
break;
|
|
}
|
|
dir_len = (i >= 0) ? i + 1 : 0;
|
|
@@ -277,6 +277,15 @@ static EFI_STATUS parseDhcp4()
|
|
strncpy(full_path, (CHAR8 *)dir, dir_len);
|
|
if (full_path[dir_len-1] == '/' && template[0] == '/')
|
|
full_path[dir_len-1] = '\0';
|
|
+ /*
|
|
+ * If the path from DHCP is using backslash instead of slash,
|
|
+ * accept that and use it in the template in the same position
|
|
+ * as well.
|
|
+ */
|
|
+ if (full_path[dir_len-1] == '\\' && template[0] == '/') {
|
|
+ full_path[dir_len-1] = '\0';
|
|
+ template[0] = '\\';
|
|
+ }
|
|
}
|
|
if (dir_len == 0 && dir[0] != '/' && template[0] == '/')
|
|
template_ofs++;
|
|
--
|
|
2.27.0
|
|
|