Subject: Win32 port BUG

Win32 port BUG

From: Guilherme Balena Versiani <guibv_at_comunip.com.br>
Date: Mon, 11 Sep 2006 16:29:41 -0300

Hello all,

I noted a strange BUG in Win32 port (ares_init.c/get_iphlpapi_dns_info()
function): when I disable the network by hand or disconnect the network
cable in Windows 2000 or Windows XP, my application gets 127.0.0.1 as
the only name server. The problem comes from 'GetNetworkParams'
function, that returns the empty string "" as the only name server in
that case. Moreover, the Windows implementation of inet_addr() returns
INADDR_LOOPBACK instead of INADDR_NONE.

So, I check the name server name by hand (by using strlen()), and
everything goes fine. That is my patch:

diff -u ares.old/ares_init.c ares/ares_init.c
--- ares.old/ares_init.c 23 Aug 2006 09:48:59 -0000
+++ ares/ares_init.c 11 Sep 2006 16:07:26 -0000
@@ -361,7 +361,8 @@
     printf ("DNS Servers:\n"
             " %s (primary)\n", fi->DnsServerList.IpAddress.String);
   }
- if (inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE &&
+ if (strlen(fi->DnsServerList.IpAddress.String) > 0 &&
+ inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE &&
       left > ip_size)
   {
     ret += sprintf (ret, "%s,", fi->DnsServerList.IpAddress.String);

Best regards,

*Guilherme Balena Versiani*
/Desenvolvedor Pesquisador
ComunIP S/A
/

Received on 2006-09-11