mirror of
https://github.com/ipxe/ipxe
synced 2025-12-21 20:40:25 +03:00
[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.
This commit is contained in:
@@ -92,8 +92,12 @@ struct uri * parse_uri ( const char *uri_string ) {
|
|||||||
uri->fragment = tmp;
|
uri->fragment = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Identify absolute/relative URI */
|
/* Identify absolute/relative URI. We ignore schemes that are
|
||||||
if ( ( tmp = strchr ( raw, ':' ) ) ) {
|
* 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 */
|
/* Absolute URI: identify hierarchical/opaque */
|
||||||
uri->scheme = raw;
|
uri->scheme = raw;
|
||||||
*(tmp++) = '\0';
|
*(tmp++) = '\0';
|
||||||
|
|||||||
Reference in New Issue
Block a user