Module: sip-router
Branch: 3.3
Commit: 2475a1beb3f9feb47dfa742c186baa329cb81241
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2475a1b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Feb 25 13:10:59 2013 +0100
modules/sqlops: Check if pv_spec is available before trying to use it.
Instead of segfaulting when the script writer has not specified enough PV
specs to hold all the query's result columns, bail out with an error message.
- backport of a21750ff6fcf87d8e3f54597bdd3f1171846e6cb
---
modules_k/sqlops/sql_api.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/modules_k/sqlops/sql_api.c b/modules_k/sqlops/sql_api.c
index 77ff97f..83b3690 100644
--- a/modules_k/sqlops/sql_api.c
+++ b/modules_k/sqlops/sql_api.c
@@ -593,6 +593,10 @@ int sql_do_pvquery(struct sip_msg *msg, sql_con_t *con, pv_elem_t *query,
pv = res;
for(j=0; j<RES_COL_N(db_res); j++)
{
+ if (pv == NULL) {
+ LM_ERR("Missing pv spec for column %d\n", j+1);
+ goto error;
+ }
if (db_val2pv_spec(msg, &RES_ROWS(db_res)[0].values[j], &pv->sname) != 0) {
LM_ERR("Failed to convert value for column %.*s\n",
RES_NAMES(db_res)[j]->len, RES_NAMES(db_res)[j]->s);