summaryrefslogtreecommitdiffstats
path: root/net/dns.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-05-16 08:37:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-05-16 08:50:33 +0200
commit611719282d891dd752e184671f74279db2fbfbb2 (patch)
treeb92d6f3fe9ab4499b0473f697ccedbf8e585f690 /net/dns.c
parent89eb305e49e70cf303fcd5e0e3117cfebc7c561c (diff)
downloadbarebox-611719282d891dd752e184671f74279db2fbfbb2.tar.gz
barebox-611719282d891dd752e184671f74279db2fbfbb2.tar.xz
dns: fix recursive loop
resolv() uses getenv_ip() which in turn calls resolv(). Fix this inifinite loop by not using getenv_ip directly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net/dns.c')
-rw-r--r--net/dns.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/net/dns.c b/net/dns.c
index e13d654215..eb96c57603 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -197,6 +197,7 @@ static void dns_handler(void *ctx, char *packet, unsigned len)
IPaddr_t resolv(char *host)
{
IPaddr_t ip;
+ const char *ns;
if (!string_to_ip(host, &ip))
return ip;
@@ -205,8 +206,14 @@ IPaddr_t resolv(char *host)
dns_state = STATE_INIT;
- ip = getenv_ip("net.nameserver");
- if (!ip)
+ ns = getenv("net.nameserver");
+ if (!ns || !*ns) {
+ printk("%s: no nameserver specified in $net.nameserver\n",
+ __func__);
+ return 0;
+ }
+
+ if (string_to_ip(ns, &ip))
return 0;
debug("resolving host %s via nameserver %s\n", host, ip_to_string(ip));