From 7e634d244898bd60c48d3c589aa1b2a8231996b9 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Wed, 12 Jan 2005 12:17:41 +0000 Subject: [PATCH] host_aton() was not handling scoped IPv6 addresses correctly. --- doc/doc-txt/ChangeLog | 5 ++++- src/src/host.c | 17 +++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 483b87134..d878174e0 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.65 2005/01/11 15:51:02 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.66 2005/01/12 12:17:41 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -297,6 +297,9 @@ Exim version 4.50 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. +68. The host_aton() function was not handling scoped IPv6 addresses (those + with, for example, "%eth0" on the end) correctly. + Exim version 4.43 ----------------- diff --git a/src/src/host.c b/src/src/host.c index 609605563..0ebdf8b84 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/host.c,v 1.6 2005/01/11 15:51:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/host.c,v 1.7 2005/01/12 12:17:41 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -735,9 +735,10 @@ host_aton(uschar *address, int *bin) int x[4]; int v4offset = 0; -/* Handle IPv6 address, which may end with an IPv4 address. This code is NOT -enclosed in #if HAVE_IPV6 in order that IPv6 addresses are recognized even if -IPv6 is not supported. */ +/* Handle IPv6 address, which may end with an IPv4 address. It may also end +with a "scope", introduced by a percent sign. This code is NOT enclosed in #if +HAVE_IPV6 in order that IPv6 addresses are recognized even if IPv6 is not +supported. */ if (Ustrchr(address, ':') != NULL) { @@ -751,17 +752,17 @@ if (Ustrchr(address, ':') != NULL) /* If the address starts with a colon, it will start with two colons. Just lose the first one, which will leave a null first component. */ - + if (*p == ':') p++; /* Split the address into components separated by colons. The input address is supposed to be checked for syntax. There was a case where this was overlooked; to guard against that happening again, check here and crash if - there is a violation. */ + there are too many components. */ - while (*p != 0) + while (*p != 0 && *p != '%') { - int len = Ustrcspn(p, ":"); + int len = Ustrcspn(p, ":%"); if (len == 0) nulloffset = ci; if (ci > 7) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Internal error: invalid IPv6 address \"%s\" passed to host_aton()", -- 2.25.1