]> git.ipfire.org Git - thirdparty/asterisk.git/commit
pjproject: clone sdp to protect against (nat) modifications
authorMichael Neuhauser <mike@firmix.at>
Tue, 30 Jun 2020 15:40:41 +0000 (17:40 +0200)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Mon, 10 Aug 2020 11:25:12 +0000 (06:25 -0500)
commit1e58da7814d169fb5e6acf098b5566226c0dacba
tree5bd674f47929bec2fc76ef1e8e9452bc541cbe6a
parent8c54be8fc9d7820303920c2d6137dbd689e1f04a
pjproject: clone sdp to protect against (nat) modifications

PJSIP, UDP transport with external_media_address and session timers
enabled. Connected to SIP server that is not in local net. Asterisk
initiated the connection and is refreshing the session after 150s
(timeout 300s). The 2nd refresh-INVITE triggered by the pjsip timer has
a malformed IP address in its SDP (garbage string). This only happens
when the SDP is modified by the nat-code to replace the local IP address
with the configured external_media_address.
Analysis: the code to modify the SDP (in
res_pjsip_session.c:session_outgoing_nat_hook() and also (redundantly?)
in res_pjsip_sdp_rtp.c:change_outgoing_sdp_stream_media_address()) uses
the tdata->pool to allocate the replacement string. But the same
pjmedia_sdp_stream that was modified for the 1st refresh-INVITE is also
used for the 2nd refresh-INVITE (because it is stored in pjmedia's
pjmedia_sdp_neg structure). The problem is, that at that moment, the
tdata->pool that holds the stringified external_media_address from the
1. refresh-INVITE has long been reused for something else.
Fix by Sauw Ming of pjproject (see
https://github.com/pjsip/pjproject/pull/2476): the local, potentially
modified pjmedia_sdp_stream is cloned in
pjproject/source/pjsip/src/pjmedia/sip_neg.c:process_answer() and the
clone is stored, thereby detaching from the tdata->pool (which is only
released *after* process_answer())

ASTERISK-28973
Reported-by: Michael Neuhauser
Change-Id: I272ac22436076596e06aa51b9fa23fd1c7734a0e
third-party/pjproject/patches/0060-clone-sdp-for-sip-timer-refresh-invite.patch [new file with mode: 0644]