From 40def059499a5bc23fd201e7b97d13867b7bd264 Mon Sep 17 00:00:00 2001 From: Joshua Colp <jcolp@digium.com> Date: Wed, 29 Aug 2018 07:18:08 -0300 Subject: [PATCH] res_fax: Handle fax gateway being started more than once. The T.38 fax gateway state machine can cause the fax gateway to be started more than once on a channel depending on the responses of the remote endpoint. This would previously leak the channel name, channel unique id, and underlying fax engine state. This change instead makes it so that if the fax gateway session is already present and not reserved the fax gateway is not started again. ASTERISK-27981 Change-Id: I552d95086860cb18f2522ee40ef47b13b6da2e0e --- res/res_fax.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/res/res_fax.c b/res/res_fax.c index 315f0003b8..f03fdc912a 100644 --- a/res/res_fax.c +++ b/res/res_fax.c @@ -2914,6 +2914,11 @@ static int fax_gateway_start(struct fax_gateway *gateway, struct ast_fax_session struct ast_fax_session *s; int start_res; + /* if the fax gateway is already started then do nothing */ + if (gateway->s && gateway->s->state != AST_FAX_STATE_RESERVED) { + return 0; + } + /* create the FAX session */ if (!(s = fax_session_new(details, chan, gateway->s, gateway->token))) { gateway->token = NULL; -- GitLab