Navigation Menu

Skip to content

Commit

Permalink
[autoboot] Avoid using uri_dup() for constructed TFTP URI
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mcb30 committed Feb 1, 2011
1 parent 3ed849b commit a325202
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/usr/autoboot.c
Expand Up @@ -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 );
Expand All @@ -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;
}
Expand Down

0 comments on commit a325202

Please sign in to comment.