res_ael: Fix pattern matching against literal '+'

When generating the regular expression that matches against existing
extensions, we need to escape literal characters that can also be
regular expression metacharacters. This was already being done for '*'
but we need to do the same for '+'.

In passing, remove some unreachable code - strcmp() is already run
immediately when entering extension_matches().

ASTERISK-14939 #close
Reported by: klaus3000

Change-Id: I8d2cccb3479168fba1b0a6704c52198b396468f1
This commit is contained in:
Sean Bright
2019-04-11 12:03:07 -04:00
parent cb282d5c17
commit 395c7ed5b7

View File

@@ -759,10 +759,10 @@ static int extension_matches(pval *here, const char *exten, const char *pattern)
*r++ = '.';
*r++ = '*';
break;
case '*':
case '*': /* regex metacharacter */
case '+': /* regex metacharacter */
*r++ = '\\';
*r++ = '*';
break;
/* fall through */
default:
*r++ = *p;
break;
@@ -792,14 +792,9 @@ static int extension_matches(pval *here, const char *exten, const char *pattern)
exten, pattern); */
return 1;
}
} else {
if ( strcmp(exten,pattern) == 0 ) {
return 1;
} else
return 0;
}
return 0;
}