[Asterisk-code-review] res pjsip/config domain aliases.c: Add check for missing dom... (asterisk[master])

Jenkins2 asteriskteam at digium.com
Mon Feb 5 16:11:21 CST 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8160 )

Change subject: res_pjsip/config_domain_aliases.c: Add check for missing domain.
......................................................................

res_pjsip/config_domain_aliases.c: Add check for missing domain.

What is the point of defining an alias and not saying what is being
aliased?

Change-Id: I98a892016ed61dcf5efeb6619fd748925103f0be
---
M res/res_pjsip/config_domain_aliases.c
1 file changed, 21 insertions(+), 2 deletions(-)

Approvals:
  Corey Farrell: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/res/res_pjsip/config_domain_aliases.c b/res/res_pjsip/config_domain_aliases.c
index 8feff05..79ea8dd 100644
--- a/res/res_pjsip/config_domain_aliases.c
+++ b/res/res_pjsip/config_domain_aliases.c
@@ -34,8 +34,9 @@
 
 static void *domain_alias_alloc(const char *name)
 {
-        struct ast_sip_domain_alias *alias = ast_sorcery_generic_alloc(sizeof(*alias), domain_alias_destroy);
+	struct ast_sip_domain_alias *alias;
 
+	alias = ast_sorcery_generic_alloc(sizeof(*alias), domain_alias_destroy);
 	if (!alias) {
 		return NULL;
 	}
@@ -48,6 +49,23 @@
 	return alias;
 }
 
+/*! \brief Apply handler for domain_alias type */
+static int domain_alias_apply(const struct ast_sorcery *sorcery, void *obj)
+{
+	struct ast_sip_domain_alias *alias = obj;
+
+	if (ast_strlen_zero(alias->domain)) {
+		/*
+		 * What is the point of defining an alias and not saying
+		 * what is being aliased?
+		 */
+		ast_log(LOG_ERROR, "%s '%s' missing required domain being aliased.\n",
+			SIP_SORCERY_DOMAIN_ALIAS_TYPE, ast_sorcery_object_get_id(alias));
+		return -1;
+	}
+	return 0;
+}
+
 /*! \brief Initialize sorcery with domain alias support */
 int ast_sip_initialize_sorcery_domain_alias(void)
 {
@@ -55,7 +73,8 @@
 
 	ast_sorcery_apply_default(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE, "config", "pjsip.conf,criteria=type=domain_alias");
 
-	if (ast_sorcery_object_register(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE, domain_alias_alloc, NULL, NULL)) {
+	if (ast_sorcery_object_register(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE,
+		domain_alias_alloc, NULL, domain_alias_apply)) {
 		return -1;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/8160
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I98a892016ed61dcf5efeb6619fd748925103f0be
Gerrit-Change-Number: 8160
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180205/e64389f0/attachment.html>


More information about the asterisk-code-review mailing list