Module: kamailio
Branch: 5.4
Commit: 782aae708701eaf8bfc97d72263d1e2e08569515
URL:
https://github.com/kamailio/kamailio/commit/782aae708701eaf8bfc97d72263d1e2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-04-15T08:34:26+02:00
db_text: safety check for lres
(cherry picked from commit 8a5b764e77d009eb6f236e74d3462bfce0d57f07)
---
Modified: src/modules/db_text/dbt_base.c
Modified: src/modules/db_text/dbt_res.c
---
Diff:
https://github.com/kamailio/kamailio/commit/782aae708701eaf8bfc97d72263d1e2…
Patch:
https://github.com/kamailio/kamailio/commit/782aae708701eaf8bfc97d72263d1e2…
---
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++) {