Skip to content

Commit

Permalink
Merge branch 'fix_sqlite_delete_update_avp_query' of https://github.c…
Browse files Browse the repository at this point in the history
…om/ar45/opensips into ar45-fix_sqlite_delete_update_avp_query

Conflicts:
	modules/db_sqlite/dbase.c
  • Loading branch information
ionutrazvanionita committed Dec 8, 2015
2 parents 9c43924 + 1882e6b commit 8be032b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/db_sqlite/dbase.c
Expand Up @@ -327,6 +327,7 @@ int db_sqlite_fetch_result(const db_con_t* _h, db_res_t** _r, const int nrows)
*/
int db_sqlite_raw_query(const db_con_t* _h, const str* _s, db_res_t** _r)
{
static char sql_str[SQL_BUF_LEN];
int ret=-1, i=0;
char* errmsg;
str select_str={"select", 6};
Expand All @@ -347,8 +348,15 @@ int db_sqlite_raw_query(const db_con_t* _h, const str* _s, db_res_t** _r)
if (_scpy.len >= select_str.len &&
str_strncasecmp(&_scpy, &select_str, select_str.len)) {
/* not a select statement; can execute the query and exit*/
if (_s->len + 1 > SQL_BUF_LEN) {
LM_ERR("query too big! try reducing the size of your query!"
"Current max size [%d]!\n", SQL_BUF_LEN);
return -1;
}
memcpy(sql_str, _s->s, _s->len);
sql_str[_s->len] = '\0';
if (sqlite3_exec(CON_CONNECTION(_h),
query_holder.s, NULL, NULL, &errmsg)) {
sql_str, NULL, NULL, &errmsg)) {
LM_ERR("query failed: %s\n", errmsg);
return -2;
}
Expand Down

0 comments on commit 8be032b

Please sign in to comment.