Module: sip-router
Branch: master
Commit: 7b64e538b350ebd520b80f668045b9f3c7d68fb9
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7b64e53…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Tue Sep 11 13:08:38 2012 +0100
modules_k/rls: Fixed issues with for() loops in DB only mode
- Found and fixed by Hugh Waite @ Crocodile RCS Ltd
---
modules_k/rls/rls_db.c | 15 +++++++++------
modules_k/rls/subscribe.c | 2 +-
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/modules_k/rls/rls_db.c b/modules_k/rls/rls_db.c
index 62f9ebe..175c355 100644
--- a/modules_k/rls/rls_db.c
+++ b/modules_k/rls/rls_db.c
@@ -121,7 +121,7 @@ int delete_expired_subs_rlsdb( void )
db1_res_t *result = NULL;
int n_query_cols = 0, n_result_cols = 0;
int r_callid_col = 0, r_to_tag_col = 0, r_from_tag_col = 0;
- int i;
+ int i, nr_rows;
subs_t subs;
str rlsubs_did = {0, 0};
db_query_f query_fn = rls_dbf.query_lock ? rls_dbf.query_lock : rls_dbf.query;
@@ -167,10 +167,13 @@ int delete_expired_subs_rlsdb( void )
if(result == NULL) goto error;
- for (i = 0; i <RES_ROW_N(result); i++)
+ rows = RES_ROWS(result);
+ nr_rows = RES_ROW_N(result);
+
+ for (i = 0; i < nr_rows; i++)
{
- rows = RES_ROWS(result);
- values = ROW_VALUES(rows);
+ memset(&subs, 0, sizeof(subs_t));
+ values = ROW_VALUES(&rows[i]);
subs.callid.s = (char *) VAL_STRING(&values[r_callid_col]);
subs.callid.len = strlen(subs.callid.s);
@@ -442,11 +445,11 @@ int update_all_subs_rlsdb(str *watcher_user, str *watcher_domain,
str *evt)
nr_rows = RES_ROW_N(result);
+ rows = RES_ROWS(result);
/* get the results and fill in return data structure */
for (loop=0; loop <nr_rows; loop++)
{
- rows = RES_ROWS(result);
- values = ROW_VALUES(rows);
+ values = ROW_VALUES(&rows[loop]);
size= sizeof(subs_t) +
( strlen(VAL_STRING(values+r_pres_uri_col))
diff --git a/modules_k/rls/subscribe.c b/modules_k/rls/subscribe.c
index 5b6c45a..a3a3771 100644
--- a/modules_k/rls/subscribe.c
+++ b/modules_k/rls/subscribe.c
@@ -327,7 +327,7 @@ int reply_200(struct sip_msg* msg, str* contact, int expires)
LM_ERR("no more pkg memory\n");
return -1;
}
- hdr_append.len = sprintf(hdr_append.s, "Expires: %d\r\n", expires);
+ hdr_append.len = sprintf(hdr_append.s, "Expires: %d\r\n", expires);
if(hdr_append.len< 0)
{
LM_ERR("unsuccessful sprintf\n");