From dd382f366070300d6baf6db9fb2eca1d36b8e9c6 Mon Sep 17 00:00:00 2001 From: Kevin Harwell Date: Tue, 27 Jan 2015 19:25:15 +0000 Subject: [PATCH] chan_sip: stale nonce causes failure When refreshing (with a small expiration) a registration that was sent to chan_sip the nonce would be considered stale and reject the registration. What was happening was that the initial registration's "dialog" still existed in the dialogs container and upon refresh the dialog match algorithm would choose that as the "dialog" instead of the newly created one. This occurred because the algorithm did not check to see if the from tag matched if authentication info was available after the 401. So, it ended up assuming the original "dialog" was a match and stopped the search. The old "dialog" of course had an old nonce, thus the stale nonce message. This fix attempts to leave the original functionality alone except in the case of a REGISTER. If a REGISTER is received if searches for an existing "dialog" matching only on the callid. If the expires value is low enough it will reuse dialog that is there, otherwise it will create a new one. ASTERISK-24715 #close Reported by: John Bigelow Review: https://reviewboard.asterisk.org/r/4367/ ........ Merged revisions 431187 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 431194 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/13.1@431200 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 2022f901fe..6a4524921b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -9225,7 +9225,8 @@ static struct sip_pvt *find_call(struct sip_request *req, struct ast_sockaddr *a } } - if (!sip_cfg.pedanticsipchecking) { + /* match on callid only for REGISTERs */ + if (!sip_cfg.pedanticsipchecking || req->method == SIP_REGISTER) { struct sip_pvt tmp_dialog = { .callid = callid, };