From 9b222dbe0e0231ff659c0171594ecead664652a7 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sat, 17 Aug 2024 20:43:25 +1000 Subject: [PATCH] pppd: Fix auth_number() to handle wildcards correctly 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 --- pppd/auth.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pppd/auth.c b/pppd/auth.c index ecd30ba..bb692d7 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -2154,7 +2154,7 @@ int auth_number(void) { struct wordlist *wp = permitted_numbers; - int l; + size_t l; /* Allow all if no authorization list. */ if (!wp) @@ -2164,9 +2164,10 @@ auth_number(void) 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; } -- 2.39.5