]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_fax: fix segfault on inactive "reserved" fax session
authorAlexei Gradinari <alex2grad@gmail.com>
Tue, 28 May 2019 20:35:17 +0000 (16:35 -0400)
committerAlexei Gradinari <alex2grad@gmail.com>
Tue, 28 May 2019 21:10:21 +0000 (17:10 -0400)
commite0a574253e9ac2f91cf2860ae2a18adf32784e56
tree7eeb52fb2d44f6db707bb706afe763513469248c
parent86fb72c4d08961f9db01818a55f0fa499d465d36
res_fax: fix segfault on inactive "reserved" fax session

The change #10017 "Handle fax gateway being started more than once"
introdiced a bug which leads to segfault in res_fax_spandsp.

The res_fax_spandsp module does not support reserving sessions, so
fax_session_reserve returns a fax session with state AST_FAX_STATE_INACTIVE.

The fax_gateway_start does not create a real fax session if the fax session
is already present and the state is not AST_FAX_STATE_RESERVED.
But the "reserved" session created for res_fax_spandsp has state
AST_FAX_STATE_INACTIVE, so fax_gateway_start not starting.

Then when fax_gateway_framehook is called and gateway T.38 state is
NEGOTIATED the call of gateway->s->tech->write(gateway->s, f) leads to
segfault, because session tech_pvt is not set, i.e. the tech session
was not initialized/started.

This patch adds check also on AST_FAX_STATE_INACTIVE to the "reserved"
session created for res_fax_spandsp will start.

This patch also adds extra check and log ERROR if tech_pvt is not set
before call tech->write.

ASTERISK-27981 #close

Change-Id: Ife3e65e5f18c902db2ff0538fccf7d28f88fa803
res/res_fax.c