Index: cdr/cdr_sqlite3_custom.c =================================================================== --- cdr/cdr_sqlite3_custom.c (revision 257023) +++ cdr/cdr_sqlite3_custom.c (working copy) @@ -50,6 +50,7 @@ #include "asterisk/pbx.h" #include "asterisk/utils.h" #include "asterisk/cli.h" +#include "asterisk/app.h" AST_MUTEX_DEFINE_STATIC(lock); @@ -63,8 +64,8 @@ static char *columns; struct values { - char *expression; AST_LIST_ENTRY(values) list; + char expression[1]; }; static AST_LIST_HEAD_STATIC(sql_values, values); @@ -117,9 +118,12 @@ static int load_values_config(const char *tmp) { - char *val = NULL; char *vals = NULL, *save = NULL; struct values *value = NULL; + int i; + AST_DECLARE_APP_ARGS(val, + AST_APP_ARG(ues)[200]; /* More than 200 columns in this CDR? Yeah, right... */ + ); if (ast_strlen_zero(tmp)) { ast_log(LOG_WARNING, "Values not specified. Module not loaded.\n"); @@ -129,17 +133,17 @@ ast_log(LOG_ERROR, "Out of memory creating temporary buffer for value '%s'\n", tmp); return -1; } - while ((val = strsep(&vals, ","))) { + AST_STANDARD_RAW_ARGS(val, vals); + for (i = 0; i < val.argc; i++) { /* Strip the single quotes off if they are there */ - val = ast_strip_quoted(val, "'", "'"); - value = ast_calloc(sizeof(char), sizeof(*value) + strlen(val) + 1); + char *v = ast_strip_quoted(val.ues[i], "'", "'"); + value = ast_calloc(sizeof(char), sizeof(*value) + strlen(v)); if (!value) { - ast_log(LOG_ERROR, "Out of memory creating entry for value '%s'\n", val); + ast_log(LOG_ERROR, "Out of memory creating entry for value '%s'\n", v); ast_free(save); return -1; } - value->expression = (char *) value + sizeof(*value); - ast_copy_string(value->expression, val, strlen(val) + 1); + strcpy(value->expression, v); /* SAFE */ AST_LIST_INSERT_TAIL(&sql_values, value, list); } ast_free(save);