[asterisk-commits] file: trunk r404593 - in /trunk: ./ res/res_pjsip_outbound_registration.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 31 14:27:05 CST 2013


Author: file
Date: Tue Dec 31 14:27:03 2013
New Revision: 404593

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404593
Log:
res_pjsip_outbound_registration: Add validation for 'server_uri' and 'client_uri'.

When applying configuration for outbound registrations the 'server_uri' and
'client_uri' fields were not validated. The code will now confirm that they
exist and that they contain parseable SIP URIs.

Reported by: Andrew Nagy
........

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

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip_outbound_registration.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Tue Dec 31 14:27:03 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404568,404581
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404568,404581,404592

Modified: trunk/res/res_pjsip_outbound_registration.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_outbound_registration.c?view=diff&rev=404593&r1=404592&r2=404593
==============================================================================
--- trunk/res/res_pjsip_outbound_registration.c (original)
+++ trunk/res/res_pjsip_outbound_registration.c Tue Dec 31 14:27:03 2013
@@ -733,6 +733,46 @@
 {
 	RAII_VAR(struct sip_outbound_registration *, existing, ast_sorcery_retrieve_by_id(sorcery, "registration", ast_sorcery_object_get_id(obj)), ao2_cleanup);
 	struct sip_outbound_registration *applied = obj;
+	pj_pool_t *pool;
+	pj_str_t tmp;
+	pjsip_uri *uri;
+
+	if (ast_strlen_zero(applied->server_uri)) {
+		ast_log(LOG_ERROR, "No server URI specified on outbound registration '%s'",
+			ast_sorcery_object_get_id(applied));
+		return -1;
+	} else if (ast_strlen_zero(applied->client_uri)) {
+		ast_log(LOG_ERROR, "No client URI specified on outbound registration '%s'\n",
+			ast_sorcery_object_get_id(applied));
+		return -1;
+	}
+
+	pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "URI Validation", 256, 256);
+	if (!pool) {
+		ast_log(LOG_ERROR, "Could not create pool for URI validation on outbound registration '%s'\n",
+			ast_sorcery_object_get_id(applied));
+		return -1;
+	}
+
+	pj_strdup2_with_null(pool, &tmp, applied->server_uri);
+	uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
+	if (!uri) {
+		ast_log(LOG_ERROR, "Invalid server URI '%s' specified on outbound registration '%s'\n",
+			applied->server_uri, ast_sorcery_object_get_id(applied));
+		pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+		return -1;
+	}
+
+	pj_strdup2_with_null(pool, &tmp, applied->client_uri);
+	uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
+	if (!uri) {
+		ast_log(LOG_ERROR, "Invalid client URI '%s' specified on outbound registration '%s'\n",
+			applied->client_uri, ast_sorcery_object_get_id(applied));
+		pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+		return -1;
+	}
+
+	pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
 
 	if (!existing) {
 		/* If no existing registration exists we can just start fresh easily */




More information about the asterisk-commits mailing list