]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: lwip: wget: initialize dns if a hostname is used in a URL
authorTim Harvey <tharvey@gateworks.com>
Fri, 30 May 2025 15:38:26 +0000 (08:38 -0700)
committerJerome Forissier <jerome.forissier@linaro.org>
Tue, 8 Jul 2025 09:07:37 +0000 (11:07 +0200)
Initialize dns servers if a hostname (vs ipaddr) is used in a URL.
Otherwise the wget will fail without displaying an error due to
dns_gethostbyname failing silently when no DNS servers are set unless
you have previously performed a 'dns <arg>' command.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
net/lwip/wget.c

index 3c39a1b59a695b36eefeff451982456d4f5a130f..f9af2fc0d2b786d8d714f2f1c9270d254ccd4f66 100644 (file)
@@ -461,6 +461,10 @@ int wget_do_request(ulong dst_addr, char *uri)
        if (!netif)
                return -1;
 
+       /* if URL with hostname init dns */
+       if (!ipaddr_aton(ctx.server_name, NULL) && net_lwip_dns_init())
+               return CMD_RET_FAILURE;
+
        memset(&conn, 0, sizeof(conn));
 #if CONFIG_IS_ENABLED(WGET_HTTPS)
        if (is_https) {