diff options
| author | Michael Brown | 2025-03-18 17:13:55 +0100 |
|---|---|---|
| committer | Michael Brown | 2025-03-18 17:21:10 +0100 |
| commit | 37ea181d8b007120bfd70629c6fdffc30145e310 (patch) | |
| tree | 2c89ac0a420474dbdc8c50d794fceece18b04b9d /src/interface/efi | |
| parent | [efi] Prescroll the display after a failed wrapped ExitBootServices() call (diff) | |
| download | ipxe-37ea181d8b007120bfd70629c6fdffc30145e310.tar.gz ipxe-37ea181d8b007120bfd70629c6fdffc30145e310.tar.xz ipxe-37ea181d8b007120bfd70629c6fdffc30145e310.zip | |
[efi] Ignore path separator characters in virtual filenames
The virtual filesystem that we provide to expose downloaded images
will erroneously interpret filenames with redundant path separators
such as ".\filename" as an attempt to open the directory, rather than
an attempt to open "filename".
This shows up most obviously when chainloading from one iPXE into
another iPXE, when the inner iPXE may end up attempting to open
".\autoexec.ipxe" from the outer iPXE's virtual filesystem. (The
erroneously opened file will have a zero length and will therefore be
ignored, but is still confusing.)
Fix by discarding any dot or backslash characters after a potential
initial backslash. This is very liberal and will accept some
syntactically invalid paths, but this is acceptable since our virtual
filesystem does not implement directories anyway.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi')
| -rw-r--r-- | src/interface/efi/efi_file.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index e10c2ec4e..48fccdbe1 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -388,8 +388,12 @@ efi_file_open ( EFI_FILE_PROTOCOL *this, EFI_FILE_PROTOCOL **new, name++; } + /* Strip redundant path separator characters */ + while ( ( *name == '\\' ) || ( *name == '.' ) ) + name++; + /* Allow root directory itself to be opened */ - if ( ( name[0] == '\0' ) || ( name[0] == '.' ) ) + if ( ! *name ) return efi_file_open_fixed ( &efi_file_root, wname, new ); /* Fail unless opening from the root */ |
