[svn-commits] mmichelson: branch mmichelson/rls-config r416805 - /team/mmichelson/rls-confi...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 19 17:45:32 CDT 2014


Author: mmichelson
Date: Thu Jun 19 17:45:26 2014
New Revision: 416805

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416805
Log:
Add integrity checking for resource_lists.


Modified:
    team/mmichelson/rls-config/res/res_pjsip_pubsub.c

Modified: team/mmichelson/rls-config/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-config/res/res_pjsip_pubsub.c?view=diff&rev=416805&r1=416804&r2=416805
==============================================================================
--- team/mmichelson/rls-config/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-config/res/res_pjsip_pubsub.c Thu Jun 19 17:45:26 2014
@@ -2071,19 +2071,38 @@
 	return 0;
 }
 
+static int resource_list_apply_handler(const struct ast_sorcery *sorcery, void *obj)
+{
+	struct resource_list *list = obj;
+
+	if (ast_strlen_zero(list->event)) {
+		ast_log(LOG_WARNING, "Resource list '%s' has no event set\n",
+				ast_sorcery_object_get_id(list));
+		return -1;
+	}
+
+	if (AST_VECTOR_SIZE(&list->items) == 0) {
+		ast_log(LOG_WARNING, "Resource list '%s' has no list items\n",
+				ast_sorcery_object_get_id(list));
+		return -1;
+	}
+
+	return 0;
+}
+
 static int apply_list_configuration(struct ast_sorcery *sorcery)
 {
 	ast_sorcery_apply_default(sorcery, "resource_list", "config",
 			"pjsip.conf,criteria=type=resource_list");
 	if (ast_sorcery_object_register(sorcery, "resource_list", resource_list_alloc,
-				NULL, NULL)) {
+				NULL, resource_list_apply_handler)) {
 		return -1;
 	}
 
 	ast_sorcery_object_field_register(sorcery, "resource_list", "type", "",
 			OPT_NOOP_T, 0, 0);
 	ast_sorcery_object_field_register(sorcery, "resource_list", "event", "",
-			OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct resource_list, event));
+			OPT_CHAR_ARRAY_T, 1, CHARFLDSET(struct resource_list, event));
 	ast_sorcery_object_field_register(sorcery, "resource_list", "full_state", "0",
 			OPT_BOOL_T, 0, FLDSET(struct resource_list, full_state));
 	ast_sorcery_object_field_register(sorcery, "resource_list", "notification_batch_interval",




More information about the svn-commits mailing list