]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Check return from pjsip_parse_uri calls
authorGeorge Joseph <gjoseph@digium.com>
Thu, 2 May 2019 18:29:49 +0000 (12:29 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Thu, 2 May 2019 18:29:49 +0000 (12:29 -0600)
Updated ast_sip_create_rdata_with_contact and registrar_find_contact
to check the return from pjsip_parse_uri before attempting to
use the uri returned.

ASTERISK-28402
Reported-by: Ross Beer
Change-Id: I9810b3b163c45ed5a56ec743586e5ce107f13ba7

res/res_pjsip.c
res/res_pjsip_registrar.c

index 7773549adfd3ce701b104e57a57cd0eff5d13e93..ba029f3c112e66cd736002e1aed453fe0068c5d9 100644 (file)
@@ -3517,6 +3517,10 @@ int ast_sip_create_rdata_with_contact(pjsip_rx_data *rdata, char *packet, const
                if (contact_hdr) {
                        contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (char *)contact,
                                strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
+                       if (!contact_hdr->uri) {
+                               ast_log(LOG_WARNING, "Unable to parse contact URI from '%s'.\n", contact);
+                               return -1;
+                       }
                }
        }
 
index fa3e1f08cfbe1f8484f0dfaa21d6ab3c0aee9593..236d846cc7ed885772e9428f185baf0b6e2796b5 100644 (file)
@@ -129,6 +129,10 @@ static int registrar_find_contact(void *obj, void *arg, int flags)
        }
 
        contact_uri = pjsip_parse_uri(details->pool, (char*)contact->uri, strlen(contact->uri), 0);
+       if (!contact_uri) {
+               ast_log(LOG_WARNING, "Unable to parse contact URI from '%s'.\n", contact->uri);
+               return 0;
+       }
 
        return (pjsip_uri_cmp(PJSIP_URI_IN_CONTACT_HDR, details->uri, contact_uri) == PJ_SUCCESS) ? CMP_MATCH : 0;
 }