diff options
author | Michael Brown <mcb30@etherboot.org> | 2008-10-24 04:08:43 +0100 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2008-10-24 04:08:43 +0100 |
commit | 3fe6bede749e6e36d9dd321273472fe418fad56e (patch) | |
tree | ca959718f121ff49cdb1157907d82d02933c5d81 /src/core | |
parent | d4c8273569b4452fe3a6f2f90557655bceeb1aa3 (diff) | |
download | ipxe-3fe6bede749e6e36d9dd321273472fe418fad56e.tar.gz |
[uri] Avoid interpreting DOS-style path names as opaque URIs
A DOS-style full path name such as "C:\Program Files\tftpboot\nbp.0"
satisfies the syntax requirements for a URI with a scheme of "C" and
an opaque portion of "\Program Files\tftpboot\nbp.0".
Add a check in parse_uri() to ignore schemes that are apparently only
a single character long; this avoids interpreting DOS-style paths in
this way, and shouldn't affect any practical URI scheme.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/uri.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/uri.c b/src/core/uri.c index cf2b071d3..7bb46da0c 100644 --- a/src/core/uri.c +++ b/src/core/uri.c @@ -92,8 +92,12 @@ struct uri * parse_uri ( const char *uri_string ) { uri->fragment = tmp; } - /* Identify absolute/relative URI */ - if ( ( tmp = strchr ( raw, ':' ) ) ) { + /* Identify absolute/relative URI. We ignore schemes that are + * apparently only a single character long, since otherwise we + * misinterpret a DOS-style path name ("C:\path\to\file") as a + * URI with scheme="C",opaque="\path\to\file". + */ + if ( ( tmp = strchr ( raw, ':' ) ) && ( tmp > ( raw + 1 ) ) ) { /* Absolute URI: identify hierarchical/opaque */ uri->scheme = raw; *(tmp++) = '\0'; |