Module: kamailio
Branch: master
Commit: 8a5b764e77d009eb6f236e74d3462bfce0d57f07
URL:
https://github.com/kamailio/kamailio/commit/8a5b764e77d009eb6f236e74d3462bf…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-04-13T09:15:10+02:00
db_text: safety check for lres
---
Modified: src/modules/db_text/dbt_base.c
Modified: src/modules/db_text/dbt_res.c
---
Diff:
https://github.com/kamailio/kamailio/commit/8a5b764e77d009eb6f236e74d3462bf…
Patch:
https://github.com/kamailio/kamailio/commit/8a5b764e77d009eb6f236e74d3462bf…
---
diff --git a/src/modules/db_text/dbt_base.c b/src/modules/db_text/dbt_base.c
index 1e5dd01514..0b4437bced 100644
--- a/src/modules/db_text/dbt_base.c
+++ b/src/modules/db_text/dbt_base.c
@@ -258,7 +258,7 @@ int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t*
_v,
dbt_column_p pPrevCol = NULL;
_tbc_temp->colv = (dbt_column_p*) shm_malloc(_nc*sizeof(dbt_column_p));
- for(i=0; i < _nc; i++) {
+ for(i=0; lres && i < _nc; i++) {
dbt_column_p pCol = dbt_column_new(_tbc->colv[ lres[i] ]->name.s, _tbc->colv[
lres[i] ]->name.len);
pCol->type = _tbc->colv[ lres[i] ]->type;
pCol->flag = _tbc->colv[ lres[i] ]->flag;
diff --git a/src/modules/db_text/dbt_res.c b/src/modules/db_text/dbt_res.c
index 16a11f2695..87adc0b6bc 100644
--- a/src/modules/db_text/dbt_res.c
+++ b/src/modules/db_text/dbt_res.c
@@ -915,7 +915,7 @@ dbt_row_p dbt_result_extract_results(dbt_table_p _dtp, dbt_row_p*
pRows, int _nr
dbt_row_p pPrvRow=NULL;
int i, n, r;
- if(!_dtp || !pRows || _ncols<=0)
+ if(!_dtp || !pRows || _ncols<=0 || !_lres)
return NULL;
for(r=0; r < _nrows; r++) {