mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] dns: fix recursive loop
Date: Wed, 16 May 2012 08:50:50 +0200	[thread overview]
Message-ID: <1337151050-5455-1-git-send-email-s.hauer@pengutronix.de> (raw)

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>
---
 net/dns.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/dns.c b/net/dns.c
index e13d654..eb96c57 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));
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2012-05-16  6:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337151050-5455-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox