diff options
author | Michael Brown <mcb30@ipxe.org> | 2016-01-21 16:24:16 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2016-01-21 18:00:33 +0000 |
commit | f0e9e55442023c2f18e62cf74fe9098e0a6f5347 (patch) | |
tree | bb6ad3c5c63bbec368795b86d3e4f897a0421381 /src/tests | |
parent | 42c2a6aab7727e7359600515471f463c65315ff0 (diff) | |
download | ipxe-f0e9e55442023c2f18e62cf74fe9098e0a6f5347.zip ipxe-f0e9e55442023c2f18e62cf74fe9098e0a6f5347.tar.gz ipxe-f0e9e55442023c2f18e62cf74fe9098e0a6f5347.tar.bz2 |
[tftp] Mangle initial slash on TFTP URIs
TFTP URIs are intrinsically problematic, since:
- TFTP servers may use either normal slashes or backslashes as a
directory separator,
- TFTP servers allow filenames to be specified using relative paths
(with no initial directory separator),
- TFTP filenames present in a DHCP filename field may use special
characters such as "?" or "#" that prevent parsing as a generic URI.
As of commit 7667536 ("[uri] Refactor URI parsing and formatting"), we
have directly constructed TFTP URIs from DHCP next-server and filename
pairs, avoiding the generic URI parser. This eliminated the problems
related to special characters, but indirectly made it impossible to
parse a "tftp://..." URI string into a TFTP URI with a non-absolute
path.
Re-introduce the convention of requiring an extra slash in a
"tftp://..." URI string in order to specify a TFTP URI with an initial
slash in the filename. For example:
tftp://192.168.0.1/boot/pxelinux.0 => RRQ "boot/pxelinux.0"
tftp://192.168.0.1//boot/pxelinux.0 => RRQ "/boot/pxelinux.0"
This is ugly, but there seems to be no other sensible way to provide
the ability to specify all possible TFTP filenames.
A side-effect of this change is that format_uri() will no longer add a
spurious initial "/" when formatting a relative URI string. This
improves the console output when fetching an image specified via a
relative URI.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/uri_test.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/tests/uri_test.c b/src/tests/uri_test.c index 42c1c43..a068ab3 100644 --- a/src/tests/uri_test.c +++ b/src/tests/uri_test.c @@ -713,9 +713,9 @@ static struct uri_pxe_test uri_pxe_absolute_path = { { .scheme = "tftp", .host = "192.168.0.2", - .path = "/absolute/path", + .path = "//absolute/path", }, - "tftp://192.168.0.2/absolute/path", + "tftp://192.168.0.2//absolute/path", }; /** PXE URI with relative path */ @@ -731,7 +731,7 @@ static struct uri_pxe_test uri_pxe_relative_path = { { .scheme = "tftp", .host = "192.168.0.3", - .path = "relative/path", + .path = "/relative/path", }, "tftp://192.168.0.3/relative/path", }; @@ -749,7 +749,7 @@ static struct uri_pxe_test uri_pxe_icky = { { .scheme = "tftp", .host = "10.0.0.6", - .path = "C:\\tftpboot\\icky#path", + .path = "/C:\\tftpboot\\icky#path", }, "tftp://10.0.0.6/C%3A\\tftpboot\\icky%23path", }; @@ -769,9 +769,9 @@ static struct uri_pxe_test uri_pxe_port = { .scheme = "tftp", .host = "192.168.0.1", .port = "4069", - .path = "/another/path", + .path = "//another/path", }, - "tftp://192.168.0.1:4069/another/path", + "tftp://192.168.0.1:4069//another/path", }; /** Current working URI test */ |