Skip to content

Commit de50249

Browse files
committed
tm: fix bogus contact built without domain
When fixing headers for fake messages (`fix_fake_req_headers` func), the function was looking for lumps that were removing the contact, because it would assume they will be the same that would add a new one (i.e. `fix_nated_contact`). However, the `toppology_hiding("U")` function, would create a del lump, but then adding 3 lumps over it. This would make the fixing bogusly learning the contact as "sip:$user" instead of hole URI. The fix for this was to make sure that there is only one ADD lump, otherwise it would point to a shorter (broken) URI. Credits go to David Trihy from Genesys for reporting and helping us troubleshoot.
1 parent b71cf95 commit de50249

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

modules/tm/t_msgbuilder.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ static inline int fix_fake_req_headers(struct sip_msg *req)
140140
struct hdr_field *hdr;
141141
struct lump *ld, *la;
142142
contact_t *c;
143+
int enclosed;
143144

144145
if (clone_headers(req, req) < 0) {
145146
LM_ERR("could not clone headers list!\n");
@@ -168,10 +169,16 @@ static inline int fix_fake_req_headers(struct sip_msg *req)
168169
la->type, ld->u.offset, ld->len,
169170
(int)(c->uri.s-req->buf), c->uri.len); */
170171
if (la->op == LUMP_ADD && la->type == HDR_CONTACT_T &&
171-
ld->u.offset == c->uri.s-req->buf &&
172-
ld->len == c->uri.len) {
172+
ld->u.offset == c->uri.s-req->buf) {
173+
/* if we don't have the same length as the URI was
174+
* initially pointing (excluding quotes), then this is
175+
* not the actual URI
176+
*/
177+
enclosed = (la->len > 2 && la->u.value[0] == '<');
178+
if (la->len != (c->uri.len + (enclosed?2:0)))
179+
continue;
173180
/* if enclosed, skip enclosing */
174-
if (la->u.value[0] == '<') {
181+
if (enclosed) {
175182
c->uri.s = la->u.value + 1;
176183
c->uri.len = la->len - 2;
177184
} else {

0 commit comments

Comments
 (0)