Fix broken inet_pton call

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4616 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-08-01 15:41:20 +00:00
parent e505d47dc8
commit 3a3a73bce3
3 changed files with 19 additions and 9 deletions

View File

@ -203,8 +203,11 @@ void DNS::dns_init()
i++;
if (i4 < 8)
{
if (insp_aton(&buf[i],&addr) == 0)
if (insp_aton(&buf[i],&addr) > 0)
{
log(DEBUG,"Add server %d, %s",i4,&buf[i]);
memcpy(&servers[i4++],&addr,sizeof(insp_inaddr));
}
}
}
}
@ -213,12 +216,18 @@ void DNS::dns_init()
void DNS::dns_init_2(const char* dnsserver)
{
log(DEBUG,"*************** DNS INIT 2 **************");
insp_inaddr addr;
i4 = 0;
srand((unsigned int) TIME);
memset(servers,'\0',sizeof(insp_inaddr) * 8);
if (insp_aton(dnsserver,&addr) == 0)
memcpy(&servers[i4++],&addr,sizeof(insp_inaddr));
log(DEBUG,"ADD DNS: %s",dnsserver);
if (insp_aton(dnsserver,&addr) > 0)
{
unsigned char* n = (unsigned char*)&addr;
log(DEBUG,"***** Add server %d, %s: %d, %d, %d, %d",i4,dnsserver,n[0],n[1],n[2],n[3]);
memcpy(&servers[i4++],&addr,sizeof(insp_inaddr));
}
}
@ -711,7 +720,7 @@ bool DNS::ReverseLookup(const std::string &ip, bool ins)
if (ServerInstance && ServerInstance->stats)
ServerInstance->stats->statsDns++;
insp_inaddr binip;
if (insp_aton(ip.c_str(), &binip) < 0)
if (insp_aton(ip.c_str(), &binip) < 1)
{
return false;
}

View File

@ -99,7 +99,7 @@ InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsi
strlcpy(this->host,ahost.c_str(),MAXBUF);
this->port = aport;
if (insp_aton(host,&addy) < 0)
if (insp_aton(host,&addy) < 1)
{
log(DEBUG,"Attempting to resolve %s",this->host);
/* Its not an ip, spawn the resolver */
@ -200,7 +200,7 @@ bool InspSocket::BindAddr()
insp_sockaddr s;
char resolved_addr[MAXBUF];
if (insp_aton(IP.c_str(),&n) < 0)
if (insp_aton(IP.c_str(),&n) < 1)
{
/* If they gave a hostname, bind to the IP it resolves to */
log(DEBUG,"Resolving host %s",IP.c_str());
@ -211,7 +211,7 @@ bool InspSocket::BindAddr()
}
}
if (insp_aton(IP.c_str(),&n) == 0)
if (insp_aton(IP.c_str(),&n) > 0)
{
log(DEBUG,"Found an IP to bind to: %s",IP.c_str());
#ifdef IPV6

View File

@ -44,7 +44,7 @@ bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port
if (*addr == '*')
*addr = 0;
if (*addr && (insp_aton(addr,&addy) < 0))
if (*addr && (insp_aton(addr,&addy) < 1))
{
/* If they gave a hostname, bind to the IP it resolves to */
if (CleanAndResolve(resolved_addr, addr, true, 1))
@ -278,5 +278,6 @@ const char* insp_ntoa(insp_inaddr n)
int insp_aton(const char* a, insp_inaddr* n)
{
return inet_pton(AF_FAMILY, a, &n);
return inet_pton(AF_FAMILY, a, n);
}