summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/dns.c13
-rw-r--r--mdk-stage1/network.c11
2 files changed, 22 insertions, 2 deletions
diff --git a/mdk-stage1/dns.c b/mdk-stage1/dns.c
index 5ba55486a..0ed98ad44 100644
--- a/mdk-stage1/dns.c
+++ b/mdk-stage1/dns.c
@@ -38,7 +38,13 @@
int mygethostbyname(char * name, struct in_addr * addr)
{
- struct hostent * h = gethostbyname(name);
+ struct hostent * h;
+
+ /* prevent from timeouts */
+ if (dns_server.s_addr == 0)
+ return -1;
+
+ h = gethostbyname(name);
if (!h) {
if (domain) {
// gethostbyname from dietlibc doesn't support domain handling
@@ -65,6 +71,11 @@ char * mygethostbyaddr(char * ipnum)
{
struct in_addr in;
struct hostent * host;
+
+ /* prevent from timeouts */
+ if (dns_server.s_addr == 0)
+ return NULL;
+
if (!inet_aton(ipnum, &in))
return NULL;
host = gethostbyaddr(&(in.s_addr), sizeof(in.s_addr) /* INADDRSZ */, AF_INET);
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
index 1eb786cc8..13085cfcc 100644
--- a/mdk-stage1/network.c
+++ b/mdk-stage1/network.c
@@ -348,8 +348,12 @@ static void static_ip_callback(char ** strings)
{
struct in_addr addr;
- if (!inet_aton(strings[0], &addr))
+ static int done = 0;
+ if (done)
+ return;
+ if (streq(strings[0], "") || !inet_aton(strings[0], &addr))
return;
+ done = 1;
if (!strcmp(strings[1], "")) {
char * ptr;
@@ -400,6 +404,11 @@ static enum return_type setup_network_interface(struct interface_info * intf)
dns_server.s_addr = 0; /* keep an understandable state */
}
+ if (streq(answers[0], answers[1])) {
+ log_message("IP and DNS are the same, guess you don't want a DNS, disabling it");
+ dns_server.s_addr = 0; /* keep an understandable state */
+ }
+
if (!inet_aton(answers[2], &gateway)) {
log_message("invalid gateway");
gateway.s_addr = 0; /* keep an understandable state */