]> git.ipfire.org Git - thirdparty/asterisk.git/commit
AST-2020-001 - res_pjsip: Return dialog locked and referenced
authorKevin Harwell <kharwell@sangoma.com>
Wed, 4 Nov 2020 20:44:13 +0000 (14:44 -0600)
committerKevin Harwell <kharwell@digium.com>
Thu, 5 Nov 2020 20:30:20 +0000 (15:30 -0500)
commit4bee789d5a6ddcab706a50c195002bab3c4a73e2
tree97579926d2486d3b9fe71d74d2e2ff969722dd43
parent86575ab79bff99086b7ba22f1be2d87d0e5a5545
AST-2020-001 - res_pjsip: Return dialog locked and referenced

pjproject returns the dialog locked and with a reference. However,
in Asterisk the method that handles this decrements the reference
and removes the lock prior to returning. This makes it possible,
under some circumstances, for another thread to free said dialog
before the thread that created it attempts to use it again. Of
course when the thread that created it tries to use a freed dialog
a crash can occur.

This patch makes it so Asterisk now returns the newly created
dialog both locked, and with an added reference. This allows the
caller to de-reference, and unlock the dialog when it is safe to
do so.

In the case of a new SIP Invite the lock, and reference are now
held for the entirety of the new invite handling process.
Otherwise it's possible for the dialog, or its dependent objects,
like the transaction, to disappear. For example if there is a TCP
transport error.

ASTERISK-29057 #close

Change-Id: I5ef645a47829596f402cf383dc02c629c618969e
(cherry picked from commit fab1ef83b283d1e28d0ab442ccf82ab1301f9ddb)
include/asterisk/res_pjsip.h
res/res_pjsip.c
res/res_pjsip_pubsub.c
res/res_pjsip_session.c