Browse Source

[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>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
a3252028d7
1 changed files with 6 additions and 6 deletions
  1. 6
    6
      src/usr/autoboot.c

+ 6
- 6
src/usr/autoboot.c View File

@@ -66,8 +66,9 @@ static struct net_device * find_boot_netdev ( void ) {
66 66
  */
67 67
 static struct uri * parse_next_server_and_filename ( struct in_addr next_server,
68 68
 						     const char *filename ) {
69
+	char buf[ 23 /* "tftp://xxx.xxx.xxx.xxx/" */ + strlen ( filename )
70
+		  + 1 /* NUL */ ];
69 71
 	struct uri *uri;
70
-	struct uri *tmp;
71 72
 
72 73
 	/* Parse filename */
73 74
 	uri = parse_uri ( filename );
@@ -81,11 +82,10 @@ static struct uri * parse_next_server_and_filename ( struct in_addr next_server,
81 82
 	 * significant for TFTP.
82 83
 	 */
83 84
 	if ( ! uri_is_absolute ( uri ) ) {
84
-		tmp = uri;
85
-		tmp->scheme = "tftp";
86
-		tmp->host = inet_ntoa ( next_server );
87
-		uri = uri_dup ( tmp );
88
-		uri_put ( tmp );
85
+		uri_put ( uri );
86
+		snprintf ( buf, sizeof ( buf ), "tftp://%s/%s",
87
+			   inet_ntoa ( next_server ), filename );
88
+		uri = parse_uri ( filename );
89 89
 		if ( ! uri )
90 90
 			return NULL;
91 91
 	}

Loading…
Cancel
Save