Allow colon in PXE bootfile URLs

- U-boot's PXE flow supports prefixing your bootfile name with an
  IP address to fetch from a server other than the DHCP server,
  e.g. `hostIPaddr:bootfilename`:
  a93907c43f
- However, this breaks bootfile paths which contain a colon, e.g.
  `f0:ad:4e:10:1b:87/7/pxelinux.cfg/default`
- This patch checks whether the `hostIPaddr` prefix is a valid
  IP address before overriding the serverIP otherwise the whole
  bootfile path is preserved

Signed-off-by: Lyle Franklin <lylejfranklin@gmail.com>
This commit is contained in:
Lyle Franklin 2022-04-16 11:36:43 -04:00 committed by Tom Rini
parent e9496ec374
commit 85f8e03b2a

View file

@ -1538,14 +1538,19 @@ int is_serverip_in_cmd(void)
int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len)
{
char *colon;
struct in_addr ip;
ip.s_addr = 0;
if (net_boot_file_name[0] == '\0')
return 0;
colon = strchr(net_boot_file_name, ':');
if (colon) {
if (ipaddr)
*ipaddr = string_to_ip(net_boot_file_name);
ip = string_to_ip(net_boot_file_name);
if (ipaddr && ip.s_addr)
*ipaddr = ip;
}
if (ip.s_addr) {
strncpy(filename, colon + 1, max_len);
} else {
strncpy(filename, net_boot_file_name, max_len);