summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorMichael Brown2011-02-01 03:56:06 +0100
committerMichael Brown2011-02-01 03:56:06 +0100
commita3252028d7be5c78254fc4a940186588c2607a28 (patch)
tree77123d3f21f51ebb43be16a47301f9e5c28a1285 /src/usr
parent[autoboot] Allow setting expansions in filename and root-path (diff)
downloadipxe-a3252028d7be5c78254fc4a940186588c2607a28.tar.gz
ipxe-a3252028d7be5c78254fc4a940186588c2607a28.tar.xz
ipxe-a3252028d7be5c78254fc4a940186588c2607a28.zip
[autoboot] Avoid using uri_dup() for constructed TFTP URI
uri_dup() chokes on duplicating a URI with a path that does not begin with a slash. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/autoboot.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index 91f1c6e8..20c67f34 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -66,8 +66,9 @@ static struct net_device * find_boot_netdev ( void ) {
*/
static struct uri * parse_next_server_and_filename ( struct in_addr next_server,
const char *filename ) {
+ char buf[ 23 /* "tftp://xxx.xxx.xxx.xxx/" */ + strlen ( filename )
+ + 1 /* NUL */ ];
struct uri *uri;
- struct uri *tmp;
/* Parse filename */
uri = parse_uri ( filename );
@@ -81,11 +82,10 @@ static struct uri * parse_next_server_and_filename ( struct in_addr next_server,
* significant for TFTP.
*/
if ( ! uri_is_absolute ( uri ) ) {
- tmp = uri;
- tmp->scheme = "tftp";
- tmp->host = inet_ntoa ( next_server );
- uri = uri_dup ( tmp );
- uri_put ( tmp );
+ uri_put ( uri );
+ snprintf ( buf, sizeof ( buf ), "tftp://%s/%s",
+ inet_ntoa ( next_server ), filename );
+ uri = parse_uri ( filename );
if ( ! uri )
return NULL;
}