From 89d973129e4596c5888cf1139a3f9b2ab1b29eb4 Mon Sep 17 00:00:00 2001 From: hm Date: Thu, 31 Jul 2003 09:13:22 +0000 Subject: Fix bug in find_matching_entry_incoming(): the loop checking the allowed incoming remote telephone numbers and subaddresses ignored the configured list completely since it was always terminated by a break at the end of the first run (which was a leftover from the implementation of subaddresses). Submitted by: Christian Ullrich --- usr.sbin/i4b/isdnd/support.c | 53 +++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'usr.sbin/i4b') diff --git a/usr.sbin/i4b/isdnd/support.c b/usr.sbin/i4b/isdnd/support.c index b6c53a8..337c215 100644 --- a/usr.sbin/i4b/isdnd/support.c +++ b/usr.sbin/i4b/isdnd/support.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2002 Hellmuth Michaelis. All rights reserved. + * Copyright (c) 1997, 2003 Hellmuth Michaelis. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,7 +29,7 @@ * * $FreeBSD$ * - * last edit-date: [Tue Mar 26 14:38:11 2002] + * last edit-date: [Thu Jul 31 11:05:16 2003] * *---------------------------------------------------------------------------*/ @@ -458,42 +458,45 @@ find_matching_entry_incoming(msg_connect_ind_t *mp) continue; } - /* check all allowed remote number's for this entry */ + /* check all allowed remote numbers for this entry */ for (n = 0; n < cep->incoming_numbers_count; n++) { incoming_number_t *in = &cep->remote_phone_incoming[n]; - if(in->number[0] == '*' && cep->usesubaddr && in->subaddr[0] == '*') - break; - - if(in->number[0] == '*' && !cep->usesubaddr) - break; - - if(in->number[0] == '*' && cep->usesubaddr && !strncmp(in->subaddr, mp->src_subaddr, strlen(in->subaddr))) - break; - - if(strncmp(in->number, mp->src_telno, strlen(in->number)) && !cep->usesubaddr) + /* + * An incoming number matches whenever the main + * phone number either matches or is a wildcard AND + * subaddresses are either not in use or match as + * well (or the required subaddress is a wildcard). + * This means that if subaddresses are in use and + * the main phone number is a wildcard, the + * subaddress is still required to match. + * + * At first glance, this does not seem logical, + * but since subaddress usage can be configured per + * entry, disregarding the subaddress if the main + * number matches would needlessly limit the user's + * flexibility. + */ + + if ((in->number[0] == '*') || (!strncmp(in->number, mp->src_telno, strlen(in->number)))) { - DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, remno %s != incomingfromno %s", i, - in->number, mp->src_telno))); - } - - if(strncmp(in->number, mp->src_telno, strlen(in->number)) && cep->usesubaddr && in->subaddr[0] == '*') - { - DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, remno %s != incomingfromno %s", i, - in->number, mp->src_telno))); + if ((!cep->usesubaddr) || (in->subaddr[0] == '*') || (!strncmp(in->subaddr, mp->src_subaddr, strlen(in->subaddr)))) + { + DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, match: remno %s = incomingfromno %s", i, + in->number, mp->src_telno))); + break; + } } - - if(strncmp(in->number, mp->src_telno, strlen(in->number)) && cep->usesubaddr && strncmp(in->subaddr, mp->src_subaddr, strlen(in->subaddr))) + else { DBGL(DL_MSG, (log(LL_DBG, "find_matching_entry_incoming: entry %d, remno %s != incomingfromno %s", i, in->number, mp->src_telno))); } - - break; } + /* If all configured remote numbers have been tested without success, proceed to the next entry. */ if (n >= cep->incoming_numbers_count) continue; -- cgit v1.1