Mercurial > masqmail
comparison src/connect.c @ 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 | 19d57eb1b6a1 |
children | 885e3d886199 |
comparison
equal
deleted
inserted
replaced
399:c7cc3c03193c | 400:6500db550a03 |
---|---|
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 */ | 18 */ |
19 #include "masqmail.h" | 19 #include "masqmail.h" |
20 | 20 |
21 static GList* | 21 static GList* |
22 resolve_ip(GList *list, gchar *ip) | 22 resolve_ip(gchar *ip) |
23 { | 23 { |
24 struct in_addr ia; | 24 struct in_addr ia; |
25 if (inet_aton(ip, &ia)) { | 25 mxip_addr mxip; |
26 mxip_addr mxip; | |
27 | 26 |
28 mxip.name = g_strdup(ip); | 27 if (!inet_aton(ip, &ia)) { |
29 mxip.pref = 0; | 28 /* No dots-and-numbers notation. */ |
30 mxip.ip = (guint32) * (guint32 *) (&ia); | 29 return NULL; |
31 list = g_list_append(list, g_memdup(&mxip, sizeof(mxip))); | |
32 } | 30 } |
33 /* logwrite(LOG_ALERT, "invalid address '%s': inet_aton() failed\n", ip); */ | 31 mxip.name = g_strdup(ip); |
34 return NULL; | 32 mxip.pref = 0; |
33 mxip.ip = (guint32) * (guint32 *) (&ia); | |
34 return g_list_append(NULL, g_memdup(&mxip, sizeof(mxip))); | |
35 } | 35 } |
36 | 36 |
37 mxip_addr* | 37 mxip_addr* |
38 connect_hostlist(int *psockfd, gchar *host, guint port, GList *addr_list) | 38 connect_hostlist(int *psockfd, gchar *host, guint port, GList *addr_list) |
39 { | 39 { |
94 | 94 |
95 DEBUG(5) debugf("connect_resolvelist entered\n"); | 95 DEBUG(5) debugf("connect_resolvelist entered\n"); |
96 | 96 |
97 h_errno = 0; | 97 h_errno = 0; |
98 | 98 |
99 if (isdigit(host[0])) { | 99 if (isdigit(*host)) { |
100 mxip_addr *addr; | 100 mxip_addr *addr; |
101 | 101 |
102 addr_list = resolve_ip(NULL, host); | 102 if ((addr_list = resolve_ip(host))) { |
103 if (addr_list) { | |
104 addr = connect_hostlist(psockfd, host, port, addr_list); | 103 addr = connect_hostlist(psockfd, host, port, addr_list); |
105 g_list_free(addr_list); | 104 g_list_free(addr_list); |
106 return addr; | 105 return addr; |
107 } | 106 } |
108 /* | 107 /* |
109 ** previous versions complained, until someone tried | 108 ** Probably a hostname that begins with a digit. |
110 ** to use a hostname out there that begins with a | 109 ** E.g. '3dwars.de'. Thus fall ... |
111 ** digit. eg. '3dwars.de'. | |
112 */ | 110 */ |
113 } | 111 } |
114 | 112 |
115 if (res_func_list == NULL) { | 113 if (res_func_list == NULL) { |
116 logwrite(LOG_ALERT, "res_funcs == NULL !!!\n"); | 114 logwrite(LOG_ALERT, "res_funcs == NULL !!!\n"); |