diff options
author | Kevin Harwell <kharwell@digium.com> | 2017-12-20 16:17:40 -0600 |
---|---|---|
committer | Kevin Harwell <kharwell@digium.com> | 2017-12-22 15:34:39 -0600 |
commit | 553306548ca4b1733b4555575775b91d55db1a99 (patch) | |
tree | 323392957aa213e4078f58d980ddac78888aae5a /res/res_pjsip_pubsub.c | |
parent | fd0ca1c3f9b972a52d48a82b492fd6bac772dc78 (diff) |
AST-2017-014: res_pjsip - Missing contact header can cause crash
Those SIP messages that create dialogs require a contact header to be present.
If the contact header was missing from the message it could cause Asterisk to
crash.
This patch checks to make sure SIP messages that create a dialog contain the
contact header. If the message does not and it is required Asterisk now returns
a "400 Missing Contact header" response. Also added NULL checks when retrieving
the contact header that were missing as a "just in case".
ASTERISK-27480 #close
Change-Id: I1810db87683fc637a9e3e1384a746037fec20afe
Diffstat (limited to 'res/res_pjsip_pubsub.c')
-rw-r--r-- | res/res_pjsip_pubsub.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index 45ba605d4..1f24de050 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -613,8 +613,12 @@ static void subscription_persistence_update(struct sip_subscription_tree *sub_tr expires = expires_hdr ? expires_hdr->ivalue : DEFAULT_PUBLISH_EXPIRES; sub_tree->persistence->expires = ast_tvadd(ast_tvnow(), ast_samp2tv(expires, 1)); - pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, contact_hdr->uri, - sub_tree->persistence->contact_uri, sizeof(sub_tree->persistence->contact_uri)); + if (contact_hdr) { + pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, contact_hdr->uri, + sub_tree->persistence->contact_uri, sizeof(sub_tree->persistence->contact_uri)); + } else { + ast_log(LOG_WARNING, "Contact not updated due to missing contact header\n"); + } /* When receiving a packet on an streaming transport, it's possible to receive more than one SIP * message at a time into the rdata->pkt_info.packet buffer. However, the rdata->msg_info.msg_buf |