<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi guys,<div>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.</div><div>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.</div><div>I believe this is where the problem happens in dialog.c in api_match_dialog:</div><div><div>                       while( (p=q_memchr(s.s,DLG_SEPARATOR,s.len))!=NULL ) {</div><div>                                if ( s.s+s.len-p-1 > rr_param.len+2 ) {</div><div>                                        if (strncmp( p+1, rr_param.s, rr_param.len)==0 &&</div><div>                                        p[rr_param.len+1]==DLG_SEPARATOR ) {</div><div>                                                p += rr_param.len+2;</div><div>                                                s.len = s.s+s.len-p;</div><div>                                                s.s = p;</div><div>                                                match_param = (void*)(&s);</div><div>                                                break;</div><div>                                        }</div><div>                                }</div><div>                                if (p+1<s.s+s.len) {</div><div>                                        s.len = s.s+s.len-p-1;</div><div>                                        s.s = p+1;</div><div>                                } else</div><div>                                        break;</div><div>                        }</div></div><div><br></div><div>And my solution is to do this instead:</div><div><div>                        while( (p=strstr(s.s,".did.")) != NULL) {</div><div>                                if(s.s+s.len-p-5>0){</div><div>                                        p += rr_param.len+2;</div><div>                                        s.len = s.s+s.len-p;</div><div>                                        s.s = p;</div><div>                                        match_param = (void*)(&s);</div><div>                                }</div><div>                        }</div></div><div>This will search for all occurrences of ".did." string, and uses the last one.</div><div>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.</div><div><br></div><div>Thanks,</div><div>Mark</div></div></div></div>