]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
sig_analog: Fix SEGV due to calling strcmp on NULL.
authorNaveen Albert <asterisk@phreaknet.org>
Mon, 18 Aug 2025 14:02:38 +0000 (10:02 -0400)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Mon, 18 Aug 2025 18:14:15 +0000 (18:14 +0000)
Add an additional check to guard against the channel application being
NULL.

Resolves: #1380

channels/sig_analog.c

index e0d57b53ee3c7b35d9da7571d32fc8b6ca43be4a..b623f25019a581cd2e0e6eb97902345cdb2ee738 100644 (file)
@@ -3168,6 +3168,10 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                ast_debug(2, "Letting this call hang up normally, since it's not the only call\n");
                        } else if (!p->owner || !p->subs[ANALOG_SUB_REAL].owner || ast_channel_state(ast) != AST_STATE_UP) {
                                ast_debug(2, "Called Subscriber Held does not apply: channel state is %d\n", ast_channel_state(ast));
+                       } else if (p->owner && p->subs[ANALOG_SUB_REAL].owner && ast_strlen_zero(ast_channel_appl(p->subs[ANALOG_SUB_REAL].owner))) {
+                               /* If the channel application is empty, it is likely a masquerade has occured, in which case don't hold any calls.
+                                * This conditional matches only executions that would have reached the strcmp below. */
+                               ast_debug(1, "Skipping Called Subscriber Held; channel has no application\n");
                        } else if (!p->owner || !p->subs[ANALOG_SUB_REAL].owner || strcmp(ast_channel_appl(p->subs[ANALOG_SUB_REAL].owner), "AppDial")) {
                                /* Called Subscriber held only applies to incoming calls, not outgoing calls.
                                 * We can't use p->outgoing because that is always true, for both incoming and outgoing calls, so it's not accurate.