[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>
This commit is contained in:
parent
3ed849bbf2
commit
a3252028d7
|
@ -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,
|
static struct uri * parse_next_server_and_filename ( struct in_addr next_server,
|
||||||
const char *filename ) {
|
const char *filename ) {
|
||||||
|
char buf[ 23 /* "tftp://xxx.xxx.xxx.xxx/" */ + strlen ( filename )
|
||||||
|
+ 1 /* NUL */ ];
|
||||||
struct uri *uri;
|
struct uri *uri;
|
||||||
struct uri *tmp;
|
|
||||||
|
|
||||||
/* Parse filename */
|
/* Parse filename */
|
||||||
uri = parse_uri ( 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.
|
* significant for TFTP.
|
||||||
*/
|
*/
|
||||||
if ( ! uri_is_absolute ( uri ) ) {
|
if ( ! uri_is_absolute ( uri ) ) {
|
||||||
tmp = uri;
|
uri_put ( uri );
|
||||||
tmp->scheme = "tftp";
|
snprintf ( buf, sizeof ( buf ), "tftp://%s/%s",
|
||||||
tmp->host = inet_ntoa ( next_server );
|
inet_ntoa ( next_server ), filename );
|
||||||
uri = uri_dup ( tmp );
|
uri = parse_uri ( filename );
|
||||||
uri_put ( tmp );
|
|
||||||
if ( ! uri )
|
if ( ! uri )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue