From 837296f7bf445ddae96250e01ec80b260f4664ce Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Thu, 9 Feb 2023 11:50:00 +0100 Subject: [PATCH] MT#56613 usrloc: correct AOR value at usrloc:contact-expired Change-Id: Icefae92196ceee1d2de297ae2dd3d5e810d5a2dd (cherry picked from commit 3daf8ae028118101dbd2c6ec38109b6cbe396dd6) --- debian/patches/series | 1 + ...-AOR-value-on-usrloc-contact-expired.patch | 97 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 debian/patches/sipwise/usrloc-correct-AOR-value-on-usrloc-contact-expired.patch diff --git a/debian/patches/series b/debian/patches/series index 7eadef323..f142c09c0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -107,6 +107,7 @@ sipwise/pv_headers-fix-build-warning.patch sipwise/pv_headers-use-memset.patch sipwise/core-str_casesearch.patch sipwise/pv_headers-rework-pvh_remove_header_param.patch +sipwise/usrloc-correct-AOR-value-on-usrloc-contact-expired.patch ### active development sipwise/tm-check-again-T-just-in-case-before-UNREF.patch upstream/tm-new-inter-module-API-function-t_find.patch diff --git a/debian/patches/sipwise/usrloc-correct-AOR-value-on-usrloc-contact-expired.patch b/debian/patches/sipwise/usrloc-correct-AOR-value-on-usrloc-contact-expired.patch new file mode 100644 index 000000000..e9c6ee3ea --- /dev/null +++ b/debian/patches/sipwise/usrloc-correct-AOR-value-on-usrloc-contact-expired.patch @@ -0,0 +1,97 @@ +From: Victor Seva +Date: Thu, 9 Feb 2023 11:45:29 +0100 +Subject: usrloc: correct AOR value on usrloc:contact-expired + +previously $ulc(x=>aor) had only the user part even with use_domain set +--- + src/modules/usrloc/udomain.c | 39 +++++++++++++++++++++++++++++++-------- + 1 file changed, 31 insertions(+), 8 deletions(-) + +diff --git a/src/modules/usrloc/udomain.c b/src/modules/usrloc/udomain.c +index 80980c4..011c846 100644 +--- a/src/modules/usrloc/udomain.c ++++ b/src/modules/usrloc/udomain.c +@@ -904,7 +904,7 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d) + db_val_t query_vals[3]; + int key_num = 2; + db1_res_t* res = NULL; +- str user, contact; ++ str user, contact, domain; + int i; + int n; + urecord_t r; +@@ -912,6 +912,9 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d) + #define RUIDBUF_SIZE 128 + char ruidbuf[RUIDBUF_SIZE]; + str ruid; ++#define AORBUF_SIZE 512 ++ char aorbuf[AORBUF_SIZE]; ++ str aor; + + if (db_mode!=DB_ONLY) { + return 0; +@@ -1004,6 +1007,14 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d) + continue; + } + user.len = strlen(user.s); ++ if(user.len < AORBUF_SIZE ) { ++ memcpy(aorbuf, user.s, user.len); ++ aor.s = aorbuf; ++ aor.len = user.len; ++ } else { ++ LM_ERR("user is too long %d\n", user.len); ++ continue; ++ } + + ci = dbrow2info(ROW_VALUES(row)+1, &contact, 0); + if (ci==0) { +@@ -1012,18 +1023,30 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d) + continue; + } + +- lock_udomain(_d, &user); ++ if(use_domain) { ++ domain.s = (char*)VAL_STRING(ROW_VALUES(row)+20); ++ domain.len = strlen(domain.s); ++ if(domain.len + aor.len < AORBUF_SIZE) { ++ aorbuf[aor.len] = '@'; ++ memcpy(aorbuf+aor.len+1, domain.s, domain.len); ++ aor.len += domain.len + 1; ++ } else { ++ LM_ERR("aor too long, using user part only\n"); ++ } ++ } ++ ++ lock_udomain(_d, &aor); + /* don't use the same static value from get_static_urecord() */ + memset( &r, 0, sizeof(struct urecord) ); +- r.aor = user; +- r.aorhash = ul_get_aorhash(&user); ++ r.aor = aor; ++ r.aorhash = ul_get_aorhash(&aor); + r.domain = _d->name; + + if ( (c=mem_insert_ucontact(&r, &contact, ci)) == 0) { + LM_ERR("inserting temporary contact failed for %.*s\n", +- user.len, user.s); ++ aor.len, aor.s); + release_urecord(&r); +- unlock_udomain(_d, &user); ++ unlock_udomain(_d, &aor); + goto error; + } + +@@ -1042,11 +1065,11 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d) + ruid.len = c->ruid.len; + } else { + LM_ERR("ruid is too long %d for %.*s\n", c->ruid.len, +- user.len, user.s); ++ aor.len, aor.s); + } + } + release_urecord(&r); +- unlock_udomain(_d, &user); ++ unlock_udomain(_d, &aor); + if(ruid.len > 0 && ul_xavp_contact_name.s != NULL) { + /* delete attributes by ruid */ + uldb_delete_attrs_ruid(_d->name, &ruid);