[asterisk-bugs] [JIRA] (ASTERISK-23254) Bad ao2_find() usage in pjsip_options.c

Richard Mudgett (JIRA) noreply at issues.asterisk.org
Thu Mar 20 16:17:18 CDT 2014


     [ https://issues.asterisk.org/jira/browse/ASTERISK-23254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard Mudgett updated ASTERISK-23254:
---------------------------------------

    Attachment: jira_asterisk_23254_v12.patch

[^jira_asterisk_23254_v12.patch] - Fixes finding an endpoint when given a contact.  The endpoint's contacts are matched by contact URI using a simple strcmp().

> Bad ao2_find() usage in pjsip_options.c
> ---------------------------------------
>
>                 Key: ASTERISK-23254
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-23254
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_pjsip
>    Affects Versions: 12.0.0
>            Reporter: Richard Mudgett
>            Assignee: Richard Mudgett
>         Attachments: jira_asterisk_23254_v12.patch
>
>
> In the res/res_pjsip/pjsip_options.c:on_endpoint() function the ao2_find is useless because it will never match anything.
> {code}
> if (ao2_find(contacts, arg, OBJ_NODATA | OBJ_POINTER)) {
> 	return CMP_MATCH;
> }
> {code}
> As a result pjsip_options.c:find_endpoints() will never return any matching endpoints and the pjsip_options.c:qualify_contact() will not have an endpoint to qualify.
> pjsip_options.c:qualify_contact() needs to check if it actually finds an endpoint before sending the qualify.  If it cannot find an endpoint it needs to generate an ERROR message and return.  A crash is likely if an endpoint is not found and the qualify message is challenged for authentication.  Alternatively, a configured default endpoint could be used as a final fallback before failing.
> {code}
> if (!endpoint_local) {
> 	struct ao2_iterator *endpoint_iterator = find_endpoints(contact);
> 	/* try to find endpoints that are associated with the contact */
> 	if (endpoint_iterator) {
> 		/* find "first" endpoint in order to authenticate - actually any
> 		   endpoint should do that matched on the contact */
> 		endpoint_local = ao2_iterator_next(endpoint_iterator);
> 		ao2_iterator_destroy(endpoint_iterator);
> 	}
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list