[asterisk-commits] mmichelson: branch 11 r372135 - in /branches/11: apps/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 4 10:26:13 CDT 2012


Author: mmichelson
Date: Tue Sep  4 10:26:07 2012
New Revision: 372135

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372135
Log:
Prevent crash from using app_page with no confbridge.conf file provided.

Also prevents other potential crashes when using aco API
with uninitialized aco_info structs.

(closes issue ASTERISK-20305)
reported by Noah Engelberth
Tested by Noah Engelberth

Review: https://reviewboard.asterisk.org/r/2086


Modified:
    branches/11/apps/app_confbridge.c
    branches/11/main/config_options.c

Modified: branches/11/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/apps/app_confbridge.c?view=diff&rev=372135&r1=372134&r2=372135
==============================================================================
--- branches/11/apps/app_confbridge.c (original)
+++ branches/11/apps/app_confbridge.c Tue Sep  4 10:26:07 2012
@@ -2832,6 +2832,10 @@
 {
 	int res = 0;
 
+	if (conf_load_config(0)) {
+		ast_log(LOG_ERROR, "Unable to load config. Not loading module.\n");
+		return AST_MODULE_LOAD_DECLINE;
+	}
 	if ((ast_custom_function_register(&confbridge_function))) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
@@ -2870,10 +2874,6 @@
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
-	if (conf_load_config(0)) {
-		ast_log(LOG_ERROR, "Unable to load config. Not loading module.\n");
-		return AST_MODULE_LOAD_DECLINE;
-	}
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: branches/11/main/config_options.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/config_options.c?view=diff&rev=372135&r1=372134&r2=372135
==============================================================================
--- branches/11/main/config_options.c (original)
+++ branches/11/main/config_options.c Tue Sep  4 10:26:07 2012
@@ -148,6 +148,10 @@
 	struct aco_type *type;
 
 	while ((type = types[idx++])) {
+		if (!type->internal) {
+			ast_log(LOG_ERROR, "Attempting to register option using uninitialized type\n");
+			return -1;
+		}
 		if (!ao2_link(type->internal->opts, opt)) {
 			while (--idx) {
 				ao2_unlink(types[idx]->internal->opts, opt);
@@ -269,6 +273,12 @@
 static struct aco_option *aco_option_find(struct aco_type *type, const char *name)
 {
 	struct aco_option *opt;
+
+	if (!type || !type->internal || !type->internal->opts) {
+		ast_log(LOG_NOTICE, "Attempting to use NULL or unitialized config type\n");
+		return NULL;
+	}
+
 	/* Try an exact match with OBJ_KEY for the common/fast case, then iterate through
 	 * all options for the regex cases */
 	if (!(opt = ao2_callback(type->internal->opts, OBJ_KEY, find_option_cb, (void *) name))) {
@@ -437,6 +447,11 @@
 
 enum aco_process_status aco_process_ast_config(struct aco_info *info, struct aco_file *file, struct ast_config *cfg)
 {
+	if (!info->internal) {
+		ast_log(LOG_ERROR, "Attempt to process %s with uninitialized aco_info\n", file->filename);
+		goto error;
+	}
+
 	if (!(info->internal->pending = info->snapshot_alloc())) {
 		ast_log(LOG_ERROR, "In %s: Could not allocate temporary objects\n", file->filename);
 		goto error;
@@ -471,6 +486,11 @@
 
 	if (!(info->files[0])) {
 		ast_log(LOG_ERROR, "No filename given, cannot proceed!\n");
+		return ACO_PROCESS_ERROR;
+	}
+
+	if (!info->internal) {
+		ast_log(LOG_ERROR, "Attempting to process uninitialized aco_info\n");
 		return ACO_PROCESS_ERROR;
 	}
 
@@ -577,6 +597,13 @@
 
 static void internal_type_destroy(struct aco_type *type)
 {
+	/* If we've already had all our internal data cleared out,
+	 * then there's no need to proceed further
+	 */
+	if (!type->internal) {
+		return;
+	}
+
 	if (type->internal->regex) {
 		regfree(type->internal->regex);
 		ast_free(type->internal->regex);




More information about the asterisk-commits mailing list