mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-11 15:18:38 +00:00
Merge "Fix ast_(v)asprintf() malloc failure usage conditions." into 13
This commit is contained in:
@@ -818,6 +818,8 @@ static int setup_mixmonitor_ds(struct mixmonitor *mixmonitor, struct ast_channel
|
|||||||
|
|
||||||
if (ast_asprintf(datastore_id, "%p", mixmonitor_ds) == -1) {
|
if (ast_asprintf(datastore_id, "%p", mixmonitor_ds) == -1) {
|
||||||
ast_log(LOG_ERROR, "Failed to allocate memory for MixMonitor ID.\n");
|
ast_log(LOG_ERROR, "Failed to allocate memory for MixMonitor ID.\n");
|
||||||
|
ast_free(mixmonitor_ds);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_mutex_init(&mixmonitor_ds->lock);
|
ast_mutex_init(&mixmonitor_ds->lock);
|
||||||
|
@@ -721,7 +721,13 @@ int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, c
|
|||||||
|
|
||||||
DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1);
|
DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1);
|
||||||
|
|
||||||
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;
|
MALLOC_FAILURE_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -193,9 +193,11 @@ static int convert_bdb_to_sqlite3(void)
|
|||||||
char *cmd;
|
char *cmd;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
ast_asprintf(&cmd, "%s/astdb2sqlite3 '%s'\n", ast_config_AST_SBIN_DIR, ast_config_AST_DB);
|
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);
|
res = ast_safe_system(cmd);
|
||||||
ast_free(cmd);
|
ast_free(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@@ -462,7 +462,7 @@ struct ast_json *ast_json_vstringf(const char *format, va_list args)
|
|||||||
|
|
||||||
if (format) {
|
if (format) {
|
||||||
int err = ast_vasprintf(&str, format, args);
|
int err = ast_vasprintf(&str, format, args);
|
||||||
if (err > 0) {
|
if (err >= 0) {
|
||||||
ret = json_string(str);
|
ret = json_string(str);
|
||||||
ast_free(str);
|
ast_free(str);
|
||||||
}
|
}
|
||||||
|
@@ -1344,7 +1344,7 @@ static struct ast_str *multi_object_blob_to_ami(void *obj)
|
|||||||
|
|
||||||
for (type = 0; type < STASIS_UMOS_MAX; ++type) {
|
for (type = 0; type < STASIS_UMOS_MAX; ++type) {
|
||||||
for (i = 0; i < AST_VECTOR_SIZE(&multi->snapshots[type]); ++i) {
|
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);
|
void *snapshot = AST_VECTOR_GET(&multi->snapshots[type], i);
|
||||||
ami_snapshot = NULL;
|
ami_snapshot = NULL;
|
||||||
|
|
||||||
@@ -1354,11 +1354,11 @@ static struct ast_str *multi_object_blob_to_ami(void *obj)
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case STASIS_UMOS_CHANNEL:
|
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;
|
break;
|
||||||
|
|
||||||
case STASIS_UMOS_BRIDGE:
|
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;
|
break;
|
||||||
|
|
||||||
case STASIS_UMOS_ENDPOINT:
|
case STASIS_UMOS_ENDPOINT:
|
||||||
@@ -1369,6 +1369,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_str_append(&ami_str, 0, "%s", ast_str_buffer(ami_snapshot));
|
||||||
ast_free(ami_snapshot);
|
ast_free(ami_snapshot);
|
||||||
}
|
}
|
||||||
|
ast_free(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2389,7 +2389,13 @@ int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, co
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
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;
|
MALLOC_FAILURE_MSG;
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
@@ -387,7 +387,6 @@ static int ari_bridges_play_helper(const char *args_media,
|
|||||||
|
|
||||||
if (ast_asprintf(playback_url, "/playbacks/%s",
|
if (ast_asprintf(playback_url, "/playbacks/%s",
|
||||||
stasis_app_playback_get_id(playback)) == -1) {
|
stasis_app_playback_get_id(playback)) == -1) {
|
||||||
playback_url = NULL;
|
|
||||||
ast_ari_response_alloc_failed(response);
|
ast_ari_response_alloc_failed(response);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -3911,8 +3911,11 @@ static int fetch_access_token(struct ast_xmpp_client_config *cfg)
|
|||||||
struct ast_json_error error;
|
struct ast_json_error error;
|
||||||
RAII_VAR(struct ast_json *, jobj, NULL, ast_json_unref);
|
RAII_VAR(struct ast_json *, jobj, NULL, ast_json_unref);
|
||||||
|
|
||||||
ast_asprintf(&cmd, "CURL(%s,client_id=%s&client_secret=%s&refresh_token=%s&grant_type=refresh_token)",
|
if (ast_asprintf(&cmd,
|
||||||
url, cfg->oauth_clientid, cfg->oauth_secret, cfg->refresh_token);
|
"CURL(%s,client_id=%s&client_secret=%s&refresh_token=%s&grant_type=refresh_token)",
|
||||||
|
url, cfg->oauth_clientid, cfg->oauth_secret, cfg->refresh_token) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ast_debug(2, "Performing OAuth 2.0 authentication for client '%s' using command: %s\n",
|
ast_debug(2, "Performing OAuth 2.0 authentication for client '%s' using command: %s\n",
|
||||||
cfg->name, cmd);
|
cfg->name, cmd);
|
||||||
|
Reference in New Issue
Block a user