Previously auth_number treated all entries in the permitted_numbers
list as if they were wildcards, i.e., as ending in '*', even if there
was no '*'. This fixes it to only treat entries ending in '*' as
wildcards; without the '*', remote_number has to match the whole entry
exactly.
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
auth_number(void)
{
struct wordlist *wp = permitted_numbers;
- int l;
+ size_t l;
/* Allow all if no authorization list. */
if (!wp)
while (wp) {
/* trailing '*' wildcard */
l = strlen(wp->word);
- if ((wp->word)[l - 1] == '*')
- l--;
- if (!strncasecmp(wp->word, remote_number, l))
+ if (l > 0 && (wp->word)[l - 1] == '*') {
+ if (!strncasecmp(wp->word, remote_number, l - 1))
+ return 1;
+ } else if (strcasecmp(wp->word, remote_number) == 0)
return 1;
wp = wp->next;
}