summaryrefslogtreecommitdiff
path: root/res/res_config_pgsql.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2012-04-17 21:10:50 +0000
committerJonathan Rose <jrose@digium.com>2012-04-17 21:10:50 +0000
commitf88a632d96bb3ed76976b2f32f5d7b7e8591afa9 (patch)
treeaf95e26373900d175d853edbc817658fa205acbe /res/res_config_pgsql.c
parent3934b0478d4962a81fcc5d20b75dbfc3aceb398e (diff)
Make use of va_args more appropriate to form in various res_config modules plus utils.
A number of va_copy operations weren't matched with a corresponding va_end in res_config_odbc. Also, there was a potential for va_end to be invoked twice on the same va_arg in utils, which would mean invoking va_end on an undefined variable... which is bad. va_end is removed from various functions in config_pgsql and config_curl since they aren't making their own copy. The invokers of those functions are responsible for calling va_end on them. (issue ASTERISK-19451) Reported by: Walter Doekes Review: https://reviewboard.asterisk.org/r/1848/ ........ Merged revisions 362354 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 362357 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362363 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_config_pgsql.c')
-rw-r--r--res/res_config_pgsql.c12
1 files changed, 0 insertions, 12 deletions
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 8eae03f5a..02c76fcfe 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -461,7 +461,6 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", newval);
- va_end(ap);
return NULL;
}
@@ -476,13 +475,11 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", newval);
- va_end(ap);
return NULL;
}
ast_str_append(&sql, 0, " AND %s%s '%s'", newparam, op, ast_str_buffer(escapebuf));
}
- va_end(ap);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
@@ -598,7 +595,6 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", newval);
- va_end(ap);
ast_config_destroy(cfg);
return NULL;
}
@@ -614,7 +610,6 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", newval);
- va_end(ap);
ast_config_destroy(cfg);
return NULL;
}
@@ -626,7 +621,6 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
ast_str_append(&sql, 0, " ORDER BY %s", initfield);
}
- va_end(ap);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
@@ -761,7 +755,6 @@ static int update_pgsql(const char *database, const char *tablename, const char
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", newval);
- va_end(ap);
release_table(table);
return -1;
}
@@ -778,20 +771,17 @@ static int update_pgsql(const char *database, const char *tablename, const char
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", newval);
- va_end(ap);
release_table(table);
return -1;
}
ast_str_append(&sql, 0, ", %s = '%s'", newparam, ast_str_buffer(escapebuf));
}
- va_end(ap);
release_table(table);
ESCAPE_STRING(escapebuf, lookup);
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", lookup);
- va_end(ap);
return -1;
}
@@ -1007,7 +997,6 @@ static int store_pgsql(const char *database, const char *table, va_list ap)
ESCAPE_STRING(buf, newval);
ast_str_append(&sql2, 0, ", '%s'", ast_str_buffer(buf));
}
- va_end(ap);
ast_str_append(&sql1, 0, "%s)", ast_str_buffer(sql2));
ast_debug(1, "PostgreSQL RealTime: Insert SQL: %s\n", ast_str_buffer(sql1));
@@ -1089,7 +1078,6 @@ static int destroy_pgsql(const char *database, const char *table, const char *ke
ESCAPE_STRING(buf2, newval);
ast_str_append(&sql, 0, " AND %s = '%s'", ast_str_buffer(buf1), ast_str_buffer(buf2));
}
- va_end(ap);
ast_debug(1, "PostgreSQL RealTime: Delete SQL: %s\n", ast_str_buffer(sql));