masqmail

changeset 373:4cab237ce923

Fixed bug in matching of allowed recipients. Thanks to Juergen Daubert for finding and reporting the issue. The code had evaluated completely different data ...
author markus schnalke <meillo@marmaro.de>
date Sat, 14 Jan 2012 11:47:57 +0100
parents b0708fac99dd
children a96bb42f597d
files src/route.c
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/src/route.c	Tue Oct 25 14:31:28 2011 +0200
     1.2 +++ b/src/route.c	Sat Jan 14 11:47:57 2012 +0100
     1.3 @@ -204,7 +204,7 @@
     1.4  		GList **rl_matching, GList **rl_others)
     1.5  {
     1.6  	GList *rcpt_node;
     1.7 -	GList *host_node = NULL;
     1.8 +	GList *pat_node = NULL;
     1.9  	address *rcpt = NULL;
    1.10  
    1.11  	if (rcpt_list == NULL)
    1.12 @@ -212,22 +212,23 @@
    1.13  
    1.14  	foreach(rcpt_list, rcpt_node) {
    1.15  		rcpt = (address *) (rcpt_node->data);
    1.16 -		host_node = NULL;
    1.17 +		pat_node = NULL;
    1.18  
    1.19  		if (addr_is_local(rcpt)) {
    1.20  			if (rl_local)
    1.21  				*rl_local = g_list_append(*rl_local, rcpt);
    1.22  		} else {
    1.23  			/*
    1.24 -			**  if patterns is NULL, host_node will be NULL,
    1.25 +			**  if patterns is NULL, pat_node will be NULL,
    1.26  			**  hence all non-locals are put to others
    1.27  			*/
    1.28 -			foreach(patterns, host_node) {
    1.29 -				gchar *host = (gchar *) (host_node->data);
    1.30 -				if (fnmatch(host, rcpt->domain, FNM_CASEFOLD) == 0)
    1.31 +			foreach(patterns, pat_node) {
    1.32 +				address *pat = (address *) (pat_node->data);
    1.33 +				if (fnmatch(pat->domain, rcpt->domain, FNM_CASEFOLD)==0 && fnmatch(pat->local_part, rcpt->local_part, 0)==0) {  /* TODO: match local_part caseless? */
    1.34  					break;
    1.35 +				}
    1.36  			}
    1.37 -			if (host_node) {
    1.38 +			if (pat_node) {
    1.39  				if (rl_matching)
    1.40  					*rl_matching = g_list_append(*rl_matching, rcpt);
    1.41  			} else {