aboutsummaryrefslogtreecommitdiffstats
path: root/main/kamailio/fix-sql-module-loading-order.patch
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-10-31 16:54:33 +0200
committerTimo Teräs <timo.teras@iki.fi>2011-10-31 16:59:16 +0200
commit3bec65c2a515813f60eb25ac55d2d7461d80a4b6 (patch)
tree40e7195a94d3fd58dd466c3f46df4b0e262e11d2 /main/kamailio/fix-sql-module-loading-order.patch
parent555633afe58703d75fc3d81343f5d1a6f35850ed (diff)
downloadaports-3bec65c2a515813f60eb25ac55d2d7461d80a4b6.tar.bz2
aports-3bec65c2a515813f60eb25ac55d2d7461d80a4b6.tar.xz
main/kamailio: fix a crash if db module is not loaded first
Diffstat (limited to 'main/kamailio/fix-sql-module-loading-order.patch')
-rw-r--r--main/kamailio/fix-sql-module-loading-order.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/main/kamailio/fix-sql-module-loading-order.patch b/main/kamailio/fix-sql-module-loading-order.patch
new file mode 100644
index 0000000000..5ba87e3288
--- /dev/null
+++ b/main/kamailio/fix-sql-module-loading-order.patch
@@ -0,0 +1,59 @@
+diff --git a/lib/srdb1/db_query.c b/lib/srdb1/db_query.c
+index dbde735..8efc15c 100644
+--- a/lib/srdb1/db_query.c
++++ b/lib/srdb1/db_query.c
+@@ -54,6 +54,10 @@ int db_do_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
+ LM_ERR("invalid parameter value\n");
+ return -1;
+ }
++ if (sql_buf == NULL) {
++ if (db_query_init() != 0)
++ return -2;
++ }
+
+ if (!_c) {
+ ret = snprintf(sql_buf, sql_buffer_size, "select * from %.*s ", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
+@@ -154,6 +158,10 @@ int db_do_insert_cmd(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v
+ LM_ERR("invalid parameter value\n");
+ return -1;
+ }
++ if (sql_buf == NULL) {
++ if (db_query_init() != 0)
++ return -2;
++ }
+
+ if(mode==1)
+ ret = snprintf(sql_buf, sql_buffer_size, "insert delayed into %.*s (",
+@@ -218,6 +226,10 @@ int db_do_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
+ LM_ERR("invalid parameter value\n");
+ return -1;
+ }
++ if (sql_buf == NULL) {
++ if (db_query_init() != 0)
++ return -2;
++ }
+
+ ret = snprintf(sql_buf, sql_buffer_size, "delete from %.*s", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
+ if (ret < 0 || ret >= sql_buffer_size) goto error;
+@@ -261,6 +273,10 @@ int db_do_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
+ LM_ERR("invalid parameter value\n");
+ return -1;
+ }
++ if (sql_buf == NULL) {
++ if (db_query_init() != 0)
++ return -2;
++ }
+
+ ret = snprintf(sql_buf, sql_buffer_size, "update %.*s set ", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
+ if (ret < 0 || ret >= sql_buffer_size) goto error;
+@@ -306,6 +322,10 @@ int db_do_replace(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
+ LM_ERR("invalid parameter value\n");
+ return -1;
+ }
++ if (sql_buf == NULL) {
++ if (db_query_init() != 0)
++ return -2;
++ }
+
+ ret = snprintf(sql_buf, sql_buffer_size, "replace %.*s (", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
+ if (ret < 0 || ret >= sql_buffer_size) goto error;