From: Philip Hazel Date: Tue, 11 Jan 2005 15:51:02 +0000 (+0000) Subject: Corrected several mis-calls of is_ip_address() that treated the result X-Git-Tag: exim-4_50~42 X-Git-Url: https://git.exim.org/users/jgh/exim.git/commitdiff_plain/a5a28604d8bf14b6521ed3ab028872b9cafd1b24 Corrected several mis-calls of is_ip_address() that treated the result as a boolean instead of an int. --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 891a3e04e..483b87134 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.64 2005/01/04 16:36:27 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.65 2005/01/11 15:51:02 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -292,6 +292,11 @@ Exim version 4.50 66. Added hosts_max_try_hardlimit to the smtp transport, default 50. +67. The string_is_ip_address() function returns 0, 4, or 6, for "no an IP + address", "IPv4 address", and "IPv6 address", respectively. Some calls of + the function were treating the return as a boolean value, which happened to + work because 0=false and not-0=true, but is not correct code. + Exim version 4.43 ----------------- diff --git a/src/src/exim.c b/src/src/exim.c index 681a713f4..c38a58c54 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/exim.c,v 1.12 2005/01/04 10:00:42 ph10 Exp $ */ +/* $Cambridge: exim/src/src/exim.c,v 1.13 2005/01/11 15:51:02 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -599,7 +599,7 @@ static int check_port(uschar *address) { int port = host_extract_port(address); -if (!string_is_ip_address(address, NULL)) +if (string_is_ip_address(address, NULL) == 0) { fprintf(stderr, "exim abandoned: \"%s\" is not an IP address\n", address); exit(EXIT_FAILURE); @@ -622,7 +622,7 @@ Arguments: flags flag bits for verify_address() exit_value to be set for failures -Returns: nothint +Returns: nothing */ static void diff --git a/src/src/host.c b/src/src/host.c index 91ba467d3..609605563 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/host.c,v 1.5 2005/01/04 10:00:42 ph10 Exp $ */ +/* $Cambridge: exim/src/src/host.c,v 1.6 2005/01/11 15:51:02 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -493,7 +493,7 @@ ip_address_item *next; while ((s = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL) { int port = host_extract_port(s); /* Leaves just the IP address */ - if (!string_is_ip_address(s, NULL)) + if (string_is_ip_address(s, NULL) == 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Malformed IP address \"%s\" in %s", s, name); diff --git a/src/src/lookups/dnsdb.c b/src/src/lookups/dnsdb.c index 7f42963a5..347adfb5e 100644 --- a/src/src/lookups/dnsdb.c +++ b/src/src/lookups/dnsdb.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/lookups/dnsdb.c,v 1.8 2005/01/04 10:00:44 ph10 Exp $ */ +/* $Cambridge: exim/src/src/lookups/dnsdb.c,v 1.9 2005/01/11 15:51:03 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -236,7 +236,7 @@ while ((domain = string_nextinlist(&keystring, &sep, buffer, sizeof(buffer))) records for different purposes where the key string is a host name). This code for doing the reversal is now in a separate function. */ - if (type == T_PTR && string_is_ip_address(domain, NULL)) + if (type == T_PTR && string_is_ip_address(domain, NULL) > 0) { dns_build_reverse(domain, rbuffer); domain = rbuffer; diff --git a/src/src/lookups/lsearch.c b/src/src/lookups/lsearch.c index 2a143576c..f91ddf89c 100644 --- a/src/src/lookups/lsearch.c +++ b/src/src/lookups/lsearch.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/lookups/lsearch.c,v 1.2 2005/01/04 10:00:44 ph10 Exp $ */ +/* $Cambridge: exim/src/src/lookups/lsearch.c,v 1.3 2005/01/11 15:51:03 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -213,7 +213,7 @@ for (last_was_eol = TRUE; int maskoffset; int save = buffer[linekeylength]; buffer[linekeylength] = 0; - if (!string_is_ip_address(buffer, &maskoffset) || + if (string_is_ip_address(buffer, &maskoffset) == 0 || !host_is_in_net(keystring, buffer, maskoffset)) continue; buffer[linekeylength] = save; } @@ -369,7 +369,7 @@ iplsearch_find(void *handle, uschar *filename, uschar *keystring, int length, { do_cache = do_cache; /* Keep picky compilers happy */ if ((length == 1 && keystring[0] == '*') || - string_is_ip_address(keystring, NULL)) + string_is_ip_address(keystring, NULL) > 0) { return internal_lsearch_find(handle, filename, keystring, length, result, errmsg, LSEARCH_IP); diff --git a/src/src/route.c b/src/src/route.c index 781dce6e1..47d95332e 100644 --- a/src/src/route.c +++ b/src/src/route.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/route.c,v 1.3 2005/01/04 10:00:42 ph10 Exp $ */ +/* $Cambridge: exim/src/src/route.c,v 1.4 2005/01/11 15:51:02 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1854,7 +1854,7 @@ if (r->translate_ip_address != NULL) DEBUG(D_route) debug_printf("%s [%s] translated to %s\n", h->name, h->address, newaddress); - if (string_is_ip_address(newaddress, NULL)) + if (string_is_ip_address(newaddress, NULL) > 0) { h->address = newaddress; continue; diff --git a/src/src/routers/dnslookup.c b/src/src/routers/dnslookup.c index 1eb215412..b5ef0478b 100644 --- a/src/src/routers/dnslookup.c +++ b/src/src/routers/dnslookup.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/routers/dnslookup.c,v 1.2 2005/01/04 10:00:44 ph10 Exp $ */ +/* $Cambridge: exim/src/src/routers/dnslookup.c,v 1.3 2005/01/11 15:51:03 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -305,7 +305,7 @@ for (;;) else { addr->message = US"all relevant MX records point to non-existent hosts"; - if (!allow_mx_to_ip && string_is_ip_address(h.name, NULL)) + if (!allow_mx_to_ip && string_is_ip_address(h.name, NULL) > 0) { addr->user_message = string_sprintf("It appears that the DNS operator for %s\n" diff --git a/src/src/routers/ipliteral.c b/src/src/routers/ipliteral.c index 11bdc6e08..b091c4e61 100644 --- a/src/src/routers/ipliteral.c +++ b/src/src/routers/ipliteral.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/routers/ipliteral.c,v 1.3 2005/01/04 10:00:44 ph10 Exp $ */ +/* $Cambridge: exim/src/src/routers/ipliteral.c,v 1.4 2005/01/11 15:51:03 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -118,7 +118,7 @@ host name to "(unnamed)". */ if (domain[0] != '[' || domain[len-1] != ']') return DECLINE; domain[len-1] = 0; /* temporarily */ -if (!string_is_ip_address(domain+1, NULL)) +if (string_is_ip_address(domain+1, NULL) == 0) { domain[len-1] = ']'; return DECLINE; diff --git a/src/src/routers/rf_lookup_hostlist.c b/src/src/routers/rf_lookup_hostlist.c index d7d19b5f8..5646315cb 100644 --- a/src/src/routers/rf_lookup_hostlist.c +++ b/src/src/routers/rf_lookup_hostlist.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/routers/rf_lookup_hostlist.c,v 1.2 2005/01/04 10:00:44 ph10 Exp $ */ +/* $Cambridge: exim/src/src/routers/rf_lookup_hostlist.c,v 1.3 2005/01/11 15:51:03 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -92,7 +92,7 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h) /* If explicitly configured to look up by name, or if the "host name" is actually an IP address, do a byname lookup. */ - else if (lookup_type == lk_byname || string_is_ip_address(h->name, NULL)) + else if (lookup_type == lk_byname || string_is_ip_address(h->name, NULL) > 0) { DEBUG(D_route|D_host_lookup) debug_printf("calling host_find_byname\n"); rc = host_find_byname(h, ignore_target_hosts, &canonical_name, TRUE); diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 738fd1cc2..a756f81db 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/transports/smtp.c,v 1.4 2005/01/04 16:36:28 ph10 Exp $ */ +/* $Cambridge: exim/src/src/transports/smtp.c,v 1.5 2005/01/11 15:51:03 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -2177,7 +2177,7 @@ for (cutoff_retry = 0; expired && /* Find by name if so configured, or if it's an IP address. We don't just copy the IP address, because we need the test-for-local to happen. */ - if (ob->gethostbyname || string_is_ip_address(host->name, NULL)) + if (ob->gethostbyname || string_is_ip_address(host->name, NULL) > 0) rc = host_find_byname(host, NULL, &canonical_name, TRUE); else { diff --git a/src/src/verify.c b/src/src/verify.c index b3712c406..591c6c03d 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/verify.c,v 1.9 2005/01/04 10:00:42 ph10 Exp $ */ +/* $Cambridge: exim/src/src/verify.c,v 1.10 2005/01/11 15:51:02 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1049,7 +1049,8 @@ while (addr_new != NULL) for (host = host_list; host != NULL; host = nexthost) { nexthost = host->next; - if (tf.gethostbyname || string_is_ip_address(host->name, NULL)) + if (tf.gethostbyname || + string_is_ip_address(host->name, NULL) > 0) (void)host_find_byname(host, NULL, &canonical_name, TRUE); else { @@ -1830,7 +1831,7 @@ if (*ss == '@') /* If the pattern is an IP address, optionally followed by a bitmask count, do a (possibly masked) comparision with the current IP address. */ -if (string_is_ip_address(ss, &maskoffset)) +if (string_is_ip_address(ss, &maskoffset) > 0) return (host_is_in_net(cb->host_address, ss, maskoffset)? OK : FAIL); /* If the item is of the form net[n]-lookup; then it is a lookup on @@ -2600,7 +2601,7 @@ while ((domain = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL while ((keydomain = string_nextinlist(&key, &keysep, keybuffer, sizeof(keybuffer))) != NULL) { - if (string_is_ip_address(keydomain, NULL)) + if (string_is_ip_address(keydomain, NULL) > 0) { uschar keyrevadd[128]; invert_address(keyrevadd, keydomain);