diff options
| author | Alberto Perez <aperezguevar@microsoft.com> | 2023-01-30 14:52:15 -0600 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2023-06-21 13:44:20 -0400 |
| commit | 0bfc3978f4a6a10e4427fdab222b0e50c3c7283c (patch) | |
| tree | c0339cde523a3396298313171df75c33bae979ce | |
| parent | 0640e136842200eb5873e9b2b02b159e15940591 (diff) | |
| download | efi-boot-shim-0bfc3978f4a6a10e4427fdab222b0e50c3c7283c.tar.gz efi-boot-shim-0bfc3978f4a6a10e4427fdab222b0e50c3c7283c.zip | |
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>
| -rw-r--r-- | netboot.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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++; |
