masqmail

changeset 400:6500db550a03

resolve_ip() appeared to be broken, in connect.c. I fixed it. In any case, NULL was returned, but if it is a valid IP address, a list should have been returned. This is fixed now.
author markus schnalke <meillo@marmaro.de>
date Tue, 21 Feb 2012 15:44:55 +0100
parents c7cc3c03193c
children 885e3d886199
files src/connect.c
diffstat 1 files changed, 13 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/src/connect.c	Tue Feb 21 15:02:07 2012 +0100
     1.2 +++ b/src/connect.c	Tue Feb 21 15:44:55 2012 +0100
     1.3 @@ -19,19 +19,19 @@
     1.4  #include "masqmail.h"
     1.5  
     1.6  static GList*
     1.7 -resolve_ip(GList *list, gchar *ip)
     1.8 +resolve_ip(gchar *ip)
     1.9  {
    1.10  	struct in_addr ia;
    1.11 -	if (inet_aton(ip, &ia)) {
    1.12 -		mxip_addr mxip;
    1.13 +	mxip_addr mxip;
    1.14  
    1.15 -		mxip.name = g_strdup(ip);
    1.16 -		mxip.pref = 0;
    1.17 -		mxip.ip = (guint32) * (guint32 *) (&ia);
    1.18 -		list = g_list_append(list, g_memdup(&mxip, sizeof(mxip)));
    1.19 +	if (!inet_aton(ip, &ia)) {
    1.20 +		/* No dots-and-numbers notation. */
    1.21 +		return NULL;
    1.22  	}
    1.23 -	/* logwrite(LOG_ALERT, "invalid address '%s': inet_aton() failed\n", ip); */
    1.24 -	return NULL;
    1.25 +	mxip.name = g_strdup(ip);
    1.26 +	mxip.pref = 0;
    1.27 +	mxip.ip = (guint32) * (guint32 *) (&ia);
    1.28 +	return g_list_append(NULL, g_memdup(&mxip, sizeof(mxip)));
    1.29  }
    1.30  
    1.31  mxip_addr*
    1.32 @@ -96,19 +96,17 @@
    1.33  
    1.34  	h_errno = 0;
    1.35  
    1.36 -	if (isdigit(host[0])) {
    1.37 +	if (isdigit(*host)) {
    1.38  		mxip_addr *addr;
    1.39  
    1.40 -		addr_list = resolve_ip(NULL, host);
    1.41 -		if (addr_list) {
    1.42 +		if ((addr_list = resolve_ip(host))) {
    1.43  			addr = connect_hostlist(psockfd, host, port, addr_list);
    1.44  			g_list_free(addr_list);
    1.45  			return addr;
    1.46  		}
    1.47  		/*
    1.48 -		**  previous versions complained, until someone tried
    1.49 -		**  to use a hostname out there that begins with a
    1.50 -		**  digit. eg. '3dwars.de'.
    1.51 +		**  Probably a hostname that begins with a digit.
    1.52 +		**  E.g. '3dwars.de'. Thus fall ...
    1.53  		*/
    1.54  	}
    1.55