diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 3637ad74686112db7c27ae613f7605705fb464a5..a167f43470a5ea1faf830e965e474ead5c015f63 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -9112,6 +9112,15 @@ static struct sip_pvt *find_call(struct sip_request *req, struct ast_sockaddr *a switch (found) { case SIP_REQ_MATCH: + sip_pvt_lock(sip_pvt_ptr); + if (args.method != SIP_RESPONSE && args.authentication_present + && strcmp(args.fromtag, sip_pvt_ptr->theirtag)) { + /* If we have a request that uses athentication and the fromtag is + * different from that in the original call dialog, update the + * fromtag in the saved call dialog */ + ast_string_field_set(sip_pvt_ptr, theirtag, args.fromtag); + } + sip_pvt_unlock(sip_pvt_ptr); ao2_iterator_destroy(iterator); dialog_unref(fork_pvt, "unref fork_pvt"); free_via(via);