Mercurial > 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 wrap: on
line diff
--- a/src/connect.c Tue Feb 21 15:02:07 2012 +0100 +++ b/src/connect.c Tue Feb 21 15:44:55 2012 +0100 @@ -19,19 +19,19 @@ #include "masqmail.h" static GList* -resolve_ip(GList *list, gchar *ip) +resolve_ip(gchar *ip) { struct in_addr ia; - if (inet_aton(ip, &ia)) { - mxip_addr mxip; + mxip_addr mxip; - mxip.name = g_strdup(ip); - mxip.pref = 0; - mxip.ip = (guint32) * (guint32 *) (&ia); - list = g_list_append(list, g_memdup(&mxip, sizeof(mxip))); + if (!inet_aton(ip, &ia)) { + /* No dots-and-numbers notation. */ + return NULL; } - /* logwrite(LOG_ALERT, "invalid address '%s': inet_aton() failed\n", ip); */ - return NULL; + mxip.name = g_strdup(ip); + mxip.pref = 0; + mxip.ip = (guint32) * (guint32 *) (&ia); + return g_list_append(NULL, g_memdup(&mxip, sizeof(mxip))); } mxip_addr* @@ -96,19 +96,17 @@ h_errno = 0; - if (isdigit(host[0])) { + if (isdigit(*host)) { mxip_addr *addr; - addr_list = resolve_ip(NULL, host); - if (addr_list) { + if ((addr_list = resolve_ip(host))) { addr = connect_hostlist(psockfd, host, port, addr_list); g_list_free(addr_list); return addr; } /* - ** previous versions complained, until someone tried - ** to use a hostname out there that begins with a - ** digit. eg. '3dwars.de'. + ** Probably a hostname that begins with a digit. + ** E.g. '3dwars.de'. Thus fall ... */ }