Skip to content

Commit a7cf397

Browse files
InterLinked1kharwell
authored andcommitted
pbx.c: Warn if there are too many includes in a context.
The PBX core uses the stack when it comes to includes, which means that a context can only contain strictly fewer than AST_PBX_MAX_STACK includes. If this is exceeded, then warnings will be emitted for each number of includes beyond this if searching for an extension in the including context, and if the extension's inclusion is beyond the stack size, it will simply not be found. To address this, we now check if there are too many includes in a context when the dialplan is reloaded so that if there is an issue, the user is aware of at "compile time" as opposed to "run time" only. Secondly, more details are printed out when this message is encountered so it's clear what has happened. ASTERISK-26719 Change-Id: Ia3700452e75a7af3391b3e82ee69f06a669f8958
1 parent 3e97156 commit a7cf397

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

main/pbx.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,7 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
25062506
q->data = NULL;
25072507
q->foundcontext = NULL;
25082508
} else if (q->stacklen >= AST_PBX_MAX_STACK) {
2509-
ast_log(LOG_WARNING, "Maximum PBX stack exceeded\n");
2509+
ast_log(LOG_WARNING, "Maximum PBX stack (%d) exceeded. Too many includes?\n", AST_PBX_MAX_STACK);
25102510
return NULL;
25112511
}
25122512

@@ -8771,8 +8771,14 @@ int ast_context_verify_includes(struct ast_context *con)
87718771
{
87728772
int idx;
87738773
int res = 0;
8774+
int includecount = ast_context_includes_count(con);
87748775

8775-
for (idx = 0; idx < ast_context_includes_count(con); idx++) {
8776+
if (includecount >= AST_PBX_MAX_STACK) {
8777+
ast_log(LOG_WARNING, "Context %s contains too many includes (%d). Maximum is %d.\n",
8778+
ast_get_context_name(con), includecount, AST_PBX_MAX_STACK);
8779+
}
8780+
8781+
for (idx = 0; idx < includecount; idx++) {
87768782
const struct ast_include *inc = ast_context_includes_get(con, idx);
87778783

87788784
if (ast_context_find(include_rname(inc))) {

0 commit comments

Comments
 (0)