Module: sip-router
Branch: master
Commit: 2e8264a3edb70cf08071b82915bcd2a40aec0cde
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2e8264a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sun Apr 15 22:44:52 2012 +0200
usrloc(k): corrected non-gruu db insert with multidomain
- if +sip.instance parameter in contact was missing and multidomain was
enabled, then inserted values didn't match proper columns
- reported by Juha Heinanen
---
modules_k/usrloc/ucontact.c | 21 ++++++++++++++-------
modules_k/usrloc/udomain.c | 2 +-
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/modules_k/usrloc/ucontact.c b/modules_k/usrloc/ucontact.c
index f8cbbe8..ff6b37f 100644
--- a/modules_k/usrloc/ucontact.c
+++ b/modules_k/usrloc/ucontact.c
@@ -510,21 +510,23 @@ int db_insert_ucontact(ucontact_t* _c)
if(_c->ruid.len>0)
{
- keys[nr_cols] = &ruid_col;
vals[nr_cols].type = DB1_STR;
vals[nr_cols].nul = 0;
vals[nr_cols].val.str_val = _c->ruid;
- nr_cols++;
+ } else {
+ vals[nr_cols].nul = 1;
}
+ nr_cols++;
if(_c->instance.len>0)
{
- keys[nr_cols] = &instance_col;
vals[nr_cols].type = DB1_STR;
vals[nr_cols].nul = 0;
vals[nr_cols].val.str_val = _c->instance;
- nr_cols++;
+ } else {
+ vals[nr_cols].nul = 1;
}
+ nr_cols++;
if (use_domain) {
vals[nr_cols].type = DB1_STR;
@@ -541,7 +543,7 @@ int db_insert_ucontact(ucontact_t* _c)
}
nr_cols++;
}
-
+
if (ul_dbf.use_table(ul_dbh, _c->domain) < 0) {
LM_ERR("sql use_table failed\n");
return -1;
@@ -672,15 +674,20 @@ int db_update_ucontact(ucontact_t* _c)
vals2[nr_cols2].type = DB1_STR;
vals2[nr_cols2].nul = 0;
vals2[nr_cols2].val.str_val = _c->ruid;
- nr_cols2++;
+ } else {
+ vals2[nr_cols2].nul = 1;
}
+ nr_cols2++;
+
if(_c->instance.len>0)
{
vals2[nr_cols2].type = DB1_STR;
vals2[nr_cols2].nul = 0;
vals2[nr_cols2].val.str_val = _c->instance;
- nr_cols2++;
+ } else {
+ vals2[nr_cols2].nul = 1;
}
+ nr_cols2++;
if (use_domain) {
vals1[3].type = DB1_STR;
diff --git a/modules_k/usrloc/udomain.c b/modules_k/usrloc/udomain.c
index 82a1dc5..31e27cf 100644
--- a/modules_k/usrloc/udomain.c
+++ b/modules_k/usrloc/udomain.c
@@ -412,7 +412,7 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
return -1;
}
} else {
- if (ul_dbf.query(_c, 0, 0, 0, columns, 0, (use_domain)?(15):(14), 0,
+ if (ul_dbf.query(_c, 0, 0, 0, columns, 0, (use_domain)?(17):(16), 0,
&res) < 0) {
LM_ERR("db_query failed\n");
return -1;