res_pjsip_nat: Don't assume a Contact header will always contain a URI.
authorJoshua Colp <jcolp@digium.com>
Tue, 7 Jan 2014 14:56:10 +0000 (14:56 +0000)
committerJoshua Colp <jcolp@digium.com>
Tue, 7 Jan 2014 14:56:10 +0000 (14:56 +0000)
If the 'rewrite_contact' option was enabled and a Contact header was received
which contained a '*' a crash would occur.

This change makes the res_pjsip_nat module ignore the Contact header if it
contains only a '*'.

(closes issue ASTERISK-23101)
Reported by: Matt Jordan
........

Merged revisions 405019 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405020 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_pjsip_nat.c

index 9a3f500..3416fff 100644 (file)
@@ -42,7 +42,7 @@ static pj_bool_t nat_on_rx_message(pjsip_rx_data *rdata)
        }
 
        if (endpoint->nat.rewrite_contact && (contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL)) &&
-               (PJSIP_URI_SCHEME_IS_SIP(contact->uri) || PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
+               !contact->star && (PJSIP_URI_SCHEME_IS_SIP(contact->uri) || PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
                pjsip_sip_uri *uri = pjsip_uri_get_uri(contact->uri);
 
                pj_cstr(&uri->host, rdata->pkt_info.src_name);