From 72641b7711f6a06a6b80624659d9670e8f621a2b Mon Sep 17 00:00:00 2001 From: Matthew Jordan Date: Mon, 9 Dec 2013 03:10:10 +0000 Subject: [PATCH] res_fax_spandsp: Always init T.38 session to avoid crashes during state change Prior to this patch, res_fax_spandsp was conservative with how it initialized the spandsp T.38 context. It would only initialize it if the driver thought the current state was a T.38 fax. While this works fine in nominal situations, in certain off nominal situations, res_fax_spandsp can believe that a T.38 fax will not occur when in fact one has started. In particular, this was discovered when res_fax would fall back to audio after timing out on a T.38 upgrade. The SIP channel driver would continue to retry the re-INVITE and - if the remote end responded after res_fax timed out with a 200 OK - a T.38 frame would be delivered to the res_fax stack when it no longer expected it. As it turns out, there does not appear to be any downside to always initializing the T.38 context, other than the actual memory allocation. Since that avoids this off nominal situation (and others which are equally likely hard to predict), this is the safest way to avoid this problem. Much thanks to Torrey as well for providing a scenario that reproduces this issue. (closes issue ASTERISK-21242) Reported by: Ashley Winters Tested by: Torrey Searle patches: always-init-t38.patch uploaded by awinters (License 6477) A_PARTY.xml uploaded by tsearle (License 5334) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@403449 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_fax_spandsp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/res/res_fax_spandsp.c b/res/res_fax_spandsp.c index 5a063d6f75..b84eb8fcc8 100644 --- a/res/res_fax_spandsp.c +++ b/res/res_fax_spandsp.c @@ -469,7 +469,7 @@ static void *spandsp_fax_new(struct ast_fax_session *s, struct ast_fax_tech_toke p->stats = &spandsp_global_stats.g711; - if (s->details->caps & AST_FAX_TECH_T38) { + if (s->details->caps & (AST_FAX_TECH_T38 | AST_FAX_TECH_AUDIO)) { if ((s->details->caps & AST_FAX_TECH_AUDIO) == 0) { /* audio mode was not requested, start in T.38 mode */ p->ist38 = 1; @@ -479,9 +479,7 @@ static void *spandsp_fax_new(struct ast_fax_session *s, struct ast_fax_tech_toke /* init t38 stuff */ t38_terminal_init(&p->t38_state, caller_mode, t38_tx_packet_handler, p); set_logging(&p->t38_state.logging, s->details); - } - if (s->details->caps & AST_FAX_TECH_AUDIO) { /* init audio stuff */ fax_init(&p->fax_state, caller_mode); set_logging(&p->fax_state.logging, s->details); -- 2.47.3