[OpenSIPS-Users] dialog.c problem finding did
M S
medeanwz at gmail.com
Fri Nov 20 12:48:50 EST 2020
Hi guys,
Checking on an issue with dialog and TH, I realized that there is a
potential bug while dialog id is added/retrieved from contact username.
If an endpoint has ".did." string in its contact name (if it
created its contact based on what opensips sent for example, by using the
same contact username and just changing the host part), then dialog module
cannot find the correct did in it - because dialog module always looks for
the first match of that string inside the username.
I believe this is where the problem happens in dialog.c in api_match_dialog:
while( (p=q_memchr(s.s,DLG_SEPARATOR,s.len))!=NULL )
{
if ( s.s+s.len-p-1 > rr_param.len+2 ) {
if (strncmp( p+1, rr_param.s,
rr_param.len)==0 &&
p[rr_param.len+1]==DLG_SEPARATOR ) {
p += rr_param.len+2;
s.len = s.s+s.len-p;
s.s = p;
match_param = (void*)(&s);
break;
}
}
if (p+1<s.s+s.len) {
s.len = s.s+s.len-p-1;
s.s = p+1;
} else
break;
}
And my solution is to do this instead:
while( (p=strstr(s.s,".did.")) != NULL) {
if(s.s+s.len-p-5>0){
p += rr_param.len+2;
s.len = s.s+s.len-p;
s.s = p;
match_param = (void*)(&s);
}
}
This will search for all occurrences of ".did." string, and uses the last
one.
My code compiles okay but I don't have a test setup to check. I can submit
a bug report to github but first I wanted to check if this is considered a
real bug, and if anyone can test whether my fix works.
Thanks,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20201120/0146bf98/attachment-0001.html>
More information about the Users
mailing list