From d27f1df3feb4ff58a8e3948b91797111d62f73e2 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Mon, 21 Nov 2005 12:04:23 +0000 Subject: [PATCH] Mend comparison bug for canonical vs non-canonical IPv6 addresses. --- doc/doc-txt/ChangeLog | 12 +++++++++++- src/src/host.c | 7 ++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 824a8d3eb..75826bdac 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.266 2005/11/21 10:24:02 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.267 2005/11/21 12:04:23 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -151,6 +151,16 @@ PH/17 A further patch from the Sieve maintainer: "Introduce the new Sieve PH/18 Exim was not recognizing the "net-" search type prefix in match_ip lists (Bugzilla #53). +PH/19 Exim expands the IPv6 address given to -bh to its full non-abbreviated + canonical form (as documented). However, after a host name lookup from + the IP address, check_host() was doing a simple string comparison with + addresses acquired from the DNS when checking that the found name did + have the original IP as one of its addresses. Since any found IPv6 + addresses are likely to be in abbreviated form, the comparison could + fail. Luckily, there already exists a function for doing the comparison + by converting both addresses to binary, so now that is used instead of + the text comparison. + Exim version 4.54 ----------------- diff --git a/src/src/host.c b/src/src/host.c index f3652c309..a5b850007 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/host.c,v 1.17 2005/11/11 10:02:04 ph10 Exp $ */ +/* $Cambridge: exim/src/src/host.c,v 1.18 2005/11/21 12:04:23 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1836,13 +1836,10 @@ for (hname = sender_host_name; hname != NULL; hname = *aliases++) if ((rc = host_find_byname(&h, NULL, NULL, FALSE)) == HOST_FOUND) { host_item *hh; - uschar *address_ipv4 = (Ustrncmp(sender_host_address, "::ffff:", 7) == 0)? - sender_host_address + 7 : sender_host_address; HDEBUG(D_host_lookup) debug_printf("checking addresses for %s\n", hname); for (hh = &h; hh != NULL; hh = hh->next) { - if ((Ustrcmp(hh->address, (Ustrchr(hh->address, ':') == NULL)? - address_ipv4 : sender_host_address)) == 0) + if (host_is_in_net(hh->address, sender_host_address, 0)) { HDEBUG(D_host_lookup) debug_printf(" %s OK\n", hh->address); ok = TRUE; -- 2.25.1