mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 20:04:50 +00:00
Fix sqlite config driver segfault and broken queries
The sqlite realtime handler assumed you had a static config configured as well. The realtime multientry handler assumed that you weren't using dynamic realtime. (closes issue ASTERISK-18354) (closes issue ASTERISK-18355) Review: https://reviewboard.asterisk.org/r/1561 ........ Merged revisions 343375 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 343393 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@343394 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1055,7 +1055,7 @@ static struct ast_variable * realtime_handler(const char *database, const char *
|
|||||||
#define QUERY "SELECT * FROM '%q' WHERE%s %q%s '%q'"
|
#define QUERY "SELECT * FROM '%q' WHERE%s %q%s '%q'"
|
||||||
/* \endcond */
|
/* \endcond */
|
||||||
|
|
||||||
query = sqlite_mprintf(QUERY, table, !strcmp(config_table, table) ? " commented = 0 AND" : "", params[0], op, vals[0]);
|
query = sqlite_mprintf(QUERY, table, (config_table && !strcmp(config_table, table)) ? " commented = 0 AND" : "", params[0], op, vals[0]);
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
ast_log(LOG_WARNING, "Unable to allocate SQL query\n");
|
ast_log(LOG_WARNING, "Unable to allocate SQL query\n");
|
||||||
@@ -1216,10 +1216,10 @@ static struct ast_config *realtime_multi_handler(const char *database,
|
|||||||
|
|
||||||
/* \cond DOXYGEN_CAN_PARSE_THIS */
|
/* \cond DOXYGEN_CAN_PARSE_THIS */
|
||||||
#undef QUERY
|
#undef QUERY
|
||||||
#define QUERY "SELECT * FROM '%q' WHERE commented = 0 AND %q%s '%q'"
|
#define QUERY "SELECT * FROM '%q' WHERE%s %q%s '%q'"
|
||||||
/* \endcond */
|
/* \endcond */
|
||||||
|
|
||||||
if (!(query = sqlite_mprintf(QUERY, table, params[0], op, tmp_str))) {
|
if (!(query = sqlite_mprintf(QUERY, table, (config_table && !strcmp(config_table, table)) ? " commented = 0 AND" : "", params[0], op, tmp_str))) {
|
||||||
ast_log(LOG_WARNING, "Unable to allocate SQL query\n");
|
ast_log(LOG_WARNING, "Unable to allocate SQL query\n");
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
ast_free(params);
|
ast_free(params);
|
||||||
|
Reference in New Issue
Block a user