diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/cli.c | 27 | ||||
-rw-r--r-- | main/db.c | 8 | ||||
-rw-r--r-- | main/format_cap.c | 9 | ||||
-rw-r--r-- | main/json.c | 2 | ||||
-rw-r--r-- | main/message.c | 14 | ||||
-rw-r--r-- | main/pbx.c | 18 | ||||
-rw-r--r-- | main/rtp_engine.c | 24 | ||||
-rw-r--r-- | main/stasis.c | 14 | ||||
-rw-r--r-- | main/stasis_channels.c | 4 | ||||
-rw-r--r-- | main/tcptls.c | 5 | ||||
-rw-r--r-- | main/utils.c | 8 |
11 files changed, 77 insertions, 56 deletions
diff --git a/main/cli.c b/main/cli.c index 0896181b0..5c16e8b7a 100644 --- a/main/cli.c +++ b/main/cli.c @@ -1362,31 +1362,6 @@ static char *handle_commandnummatches(struct ast_cli_entry *e, int cmd, struct a return CLI_SUCCESS; } -static char *handle_commandcomplete(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) -{ - char *buf; - switch (cmd) { - case CLI_INIT: - e->command = "_command complete"; - e->usage = - "Usage: _command complete \"<line>\" text state\n" - " This function is used internally to help with command completion and should.\n" - " never be called by the user directly.\n"; - return NULL; - case CLI_GENERATE: - return NULL; - } - if (a->argc != 5) - return CLI_SHOWUSAGE; - buf = __ast_cli_generator(a->argv[2], a->argv[3], atoi(a->argv[4]), 0); - if (buf) { - ast_cli(a->fd, "%s", buf); - ast_free(buf); - } else - ast_cli(a->fd, "NULL\n"); - return CLI_SUCCESS; -} - struct channel_set_debug_args { int fd; int is_off; @@ -1817,8 +1792,6 @@ static char *handle_cli_wait_fullybooted(struct ast_cli_entry *e, int cmd, struc static char *handle_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static struct ast_cli_entry cli_cli[] = { - /* Deprecated, but preferred command is now consolidated (and already has a deprecated command for it). */ - AST_CLI_DEFINE(handle_commandcomplete, "Command complete"), AST_CLI_DEFINE(handle_commandnummatches, "Returns number of command matches"), AST_CLI_DEFINE(handle_commandmatchesarray, "Returns command matches array"), @@ -191,9 +191,11 @@ static int convert_bdb_to_sqlite3(void) char *cmd; int res; - ast_asprintf(&cmd, "%s/astdb2sqlite3 '%s'\n", ast_config_AST_SBIN_DIR, ast_config_AST_DB); - res = ast_safe_system(cmd); - ast_free(cmd); + res = ast_asprintf(&cmd, "%s/astdb2sqlite3 '%s'\n", ast_config_AST_SBIN_DIR, ast_config_AST_DB); + if (0 <= res) { + res = ast_safe_system(cmd); + ast_free(cmd); + } return res; } diff --git a/main/format_cap.c b/main/format_cap.c index b0897c001..d71ccdbaa 100644 --- a/main/format_cap.c +++ b/main/format_cap.c @@ -160,13 +160,16 @@ static inline int format_cap_framed_init(struct format_cap_framed *framed, struc } list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format)); + /* This takes the allocation reference */ + if (AST_VECTOR_APPEND(&cap->preference_order, framed)) { + ao2_ref(framed, -1); + return -1; + } + /* Order doesn't matter for formats, so insert at the head for performance reasons */ ao2_ref(framed, +1); AST_LIST_INSERT_HEAD(list, framed, entry); - /* This takes the allocation reference */ - AST_VECTOR_APPEND(&cap->preference_order, framed); - cap->framing = MIN(cap->framing, framing ? framing : ast_format_get_default_ms(format)); return 0; diff --git a/main/json.c b/main/json.c index 9004978b4..56df7f401 100644 --- a/main/json.c +++ b/main/json.c @@ -460,7 +460,7 @@ struct ast_json *ast_json_vstringf(const char *format, va_list args) if (format) { int err = ast_vasprintf(&str, format, args); - if (err > 0) { + if (err >= 0) { ret = json_string(str); ast_free(str); } diff --git a/main/message.c b/main/message.c index fcdf705fe..ac7965ea7 100644 --- a/main/message.c +++ b/main/message.c @@ -1362,7 +1362,12 @@ int ast_msg_tech_register(const struct ast_msg_tech *tech) return -1; } - AST_VECTOR_APPEND(&msg_techs, tech); + if (AST_VECTOR_APPEND(&msg_techs, tech)) { + ast_log(LOG_ERROR, "Failed to register message technology for '%s'\n", + tech->name); + ast_rwlock_unlock(&msg_techs_lock); + return -1; + } ast_verb(3, "Message technology '%s' registered.\n", tech->name); ast_rwlock_unlock(&msg_techs_lock); @@ -1417,7 +1422,12 @@ int ast_msg_handler_register(const struct ast_msg_handler *handler) return -1; } - AST_VECTOR_APPEND(&msg_handlers, handler); + if (AST_VECTOR_APPEND(&msg_handlers, handler)) { + ast_log(LOG_ERROR, "Failed to register message handler for '%s'\n", + handler->name); + ast_rwlock_unlock(&msg_handlers_lock); + return -1; + } ast_verb(2, "Message handler '%s' registered.\n", handler->name); ast_rwlock_unlock(&msg_handlers_lock); diff --git a/main/pbx.c b/main/pbx.c index 2366b72b0..b5602b55c 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -6692,7 +6692,11 @@ int ast_context_add_include2(struct ast_context *con, const char *value, } /* ... include new context into context list, unlock, return */ - AST_VECTOR_APPEND(&con->includes, new_include); + if (AST_VECTOR_APPEND(&con->includes, new_include)) { + include_free(new_include); + ast_unlock_context(con); + return -1; + } ast_verb(3, "Including context '%s' in context '%s'\n", ast_get_include_name(new_include), ast_get_context_name(con)); @@ -6754,7 +6758,11 @@ int ast_context_add_switch2(struct ast_context *con, const char *value, } /* ... sw new context into context list, unlock, return */ - AST_VECTOR_APPEND(&con->alts, new_sw); + if (AST_VECTOR_APPEND(&con->alts, new_sw)) { + sw_free(new_sw); + ast_unlock_context(con); + return -1; + } ast_verb(3, "Including switch '%s/%s' in context '%s'\n", ast_get_switch_name(new_sw), ast_get_switch_data(new_sw), ast_get_context_name(con)); @@ -6842,7 +6850,11 @@ int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const return -1; } } - AST_VECTOR_APPEND(&con->ignorepats, ignorepat); + if (AST_VECTOR_APPEND(&con->ignorepats, ignorepat)) { + ignorepat_free(ignorepat); + ast_unlock_context(con); + return -1; + } ast_unlock_context(con); return 0; diff --git a/main/rtp_engine.c b/main/rtp_engine.c index 0aed8e97c..2431ffc0c 100644 --- a/main/rtp_engine.c +++ b/main/rtp_engine.c @@ -802,7 +802,10 @@ static void rtp_codecs_payload_replace_rx(struct ast_rtp_codecs *codecs, int pay ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_rx, payload), "cleaning up rx mapping vector element about to be replaced"); } - AST_VECTOR_REPLACE(&codecs->payload_mapping_rx, payload, new_type); + if (AST_VECTOR_REPLACE(&codecs->payload_mapping_rx, payload, new_type)) { + ao2_ref(new_type, -1); + return; + } payload_mapping_rx_clear_primary(codecs, new_type); } @@ -924,7 +927,10 @@ static void rtp_codecs_payloads_copy_tx(struct ast_rtp_codecs *src, struct ast_r ao2_t_cleanup(AST_VECTOR_GET(&dest->payload_mapping_tx, idx), "cleaning up tx mapping vector element about to be replaced"); } - AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, type); + if (AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, type)) { + ao2_ref(type, -1); + continue; + } if (instance && instance->engine && instance->engine->payload_set) { ao2_lock(instance); @@ -1038,9 +1044,10 @@ void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct as ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload), "cleaning up replaced tx payload type"); } - AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type); - if (instance && instance->engine && instance->engine->payload_set) { + if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type)) { + ao2_ref(new_type, -1); + } else if (instance && instance->engine && instance->engine->payload_set) { ao2_lock(instance); instance->engine->payload_set(instance, payload, new_type->asterisk_format, new_type->format, new_type->rtp_code); ao2_unlock(instance); @@ -1116,9 +1123,10 @@ int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, pt), "cleaning up replaced tx payload type"); } - AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type); - if (instance && instance->engine && instance->engine->payload_set) { + if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type)) { + ao2_ref(new_type, -1); + } else if (instance && instance->engine && instance->engine->payload_set) { ao2_lock(instance); instance->engine->payload_set(instance, pt, new_type->asterisk_format, new_type->format, new_type->rtp_code); ao2_unlock(instance); @@ -1215,7 +1223,9 @@ int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int pay if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) { ao2_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload)); } - AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type); + if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type)) { + ao2_ref(type, -1); + } } else { ao2_ref(type, -1); } diff --git a/main/stasis.c b/main/stasis.c index 4328b8436..186d88fdd 100644 --- a/main/stasis.c +++ b/main/stasis.c @@ -908,7 +908,7 @@ struct stasis_forward *stasis_forward_all(struct stasis_topic *from_topic, { int res; size_t idx; - RAII_VAR(struct stasis_forward *, forward, NULL, ao2_cleanup); + struct stasis_forward *forward; if (!from_topic || !to_topic) { return NULL; @@ -921,7 +921,7 @@ struct stasis_forward *stasis_forward_all(struct stasis_topic *from_topic, /* Forwards to ourselves are implicit. */ if (to_topic == from_topic) { - return ao2_bump(forward); + return forward; } forward->from_topic = ao2_bump(from_topic); @@ -932,6 +932,7 @@ struct stasis_forward *stasis_forward_all(struct stasis_topic *from_topic, if (res != 0) { ao2_unlock(from_topic); ao2_unlock(to_topic); + ao2_ref(forward, -1); return NULL; } @@ -941,7 +942,7 @@ struct stasis_forward *stasis_forward_all(struct stasis_topic *from_topic, ao2_unlock(from_topic); ao2_unlock(to_topic); - return ao2_bump(forward); + return forward; } static void subscription_change_dtor(void *obj) @@ -1341,7 +1342,7 @@ static struct ast_str *multi_object_blob_to_ami(void *obj) for (type = 0; type < STASIS_UMOS_MAX; ++type) { for (i = 0; i < AST_VECTOR_SIZE(&multi->snapshots[type]); ++i) { - char *name = ""; + char *name = NULL; void *snapshot = AST_VECTOR_GET(&multi->snapshots[type], i); ami_snapshot = NULL; @@ -1351,11 +1352,11 @@ static struct ast_str *multi_object_blob_to_ami(void *obj) switch (type) { case STASIS_UMOS_CHANNEL: - ami_snapshot = ast_manager_build_channel_state_string_prefix(snapshot, name); + ami_snapshot = ast_manager_build_channel_state_string_prefix(snapshot, name ?: ""); break; case STASIS_UMOS_BRIDGE: - ami_snapshot = ast_manager_build_bridge_state_string_prefix(snapshot, name); + ami_snapshot = ast_manager_build_bridge_state_string_prefix(snapshot, name ?: ""); break; case STASIS_UMOS_ENDPOINT: @@ -1366,6 +1367,7 @@ static struct ast_str *multi_object_blob_to_ami(void *obj) ast_str_append(&ami_str, 0, "%s", ast_str_buffer(ami_snapshot)); ast_free(ami_snapshot); } + ast_free(name); } } diff --git a/main/stasis_channels.c b/main/stasis_channels.c index dd71b8651..b81dbe599 100644 --- a/main/stasis_channels.c +++ b/main/stasis_channels.c @@ -891,7 +891,7 @@ struct ast_json *ast_channel_snapshot_to_json( const struct ast_channel_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize) { - RAII_VAR(struct ast_json *, json_chan, NULL, ast_json_unref); + struct ast_json *json_chan; if (snapshot == NULL || (sanitize && sanitize->channel_snapshot @@ -924,7 +924,7 @@ struct ast_json *ast_channel_snapshot_to_json( ast_json_object_set(json_chan, "channelvars", ast_json_channel_vars(snapshot->ari_vars)); } - return ast_json_ref(json_chan); + return json_chan; } int ast_channel_snapshot_cep_equal( diff --git a/main/tcptls.c b/main/tcptls.c index 4a95f72ef..a6d0538af 100644 --- a/main/tcptls.c +++ b/main/tcptls.c @@ -316,7 +316,10 @@ static void __ssl_setup_certs(struct ast_tls_config *cfg, const size_t cert_file static int __ssl_setup(struct ast_tls_config *cfg, int client) { #ifndef DO_SSL - cfg->enabled = 0; + if (cfg->enabled) { + ast_log(LOG_NOTICE, "Configured without OpenSSL Development Headers"); + cfg->enabled = 0; + } return 0; #else int disable_ssl = 0; diff --git a/main/utils.c b/main/utils.c index a73bf9d42..c553207b6 100644 --- a/main/utils.c +++ b/main/utils.c @@ -2340,7 +2340,13 @@ int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, c va_list ap; va_start(ap, fmt); - if ((res = vasprintf(ret, fmt, ap)) == -1) { + res = vasprintf(ret, fmt, ap); + if (res < 0) { + /* + * *ret is undefined so set to NULL to ensure it is + * initialized to something useful. + */ + *ret = NULL; MALLOC_FAILURE_MSG; } va_end(ap); |