X-Git-Url: http://git.asterisk.org/gitweb/?p=asterisk%2Fasterisk.git;a=blobdiff_plain;f=channels%2Fchan_sip.c;h=0117197b6ed0b4de743a1b48e8f4a5a5ed0fb232;hp=4e78b96beb070e6859d341fb7e7a606abceec240;hb=28fe3938b7795a1cd1b1a448065b1a91857ca28d;hpb=df649a867125cd4ec641b420ec013c78ee82384a;ds=sidebyside diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 4e78b96..0117197 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -8967,7 +8967,11 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, in seqno = p->ocseq; } - if (sipmethod == SIP_CANCEL || sipmethod == SIP_INVITE) { + /* A CANCEL must have the same branch as the INVITE that it is canceling. + * Similarly, if we need to re-send an INVITE with auth credentials, then we + * need to use the same branch as we did the first time we sent the INVITE. + */ + if (sipmethod == SIP_CANCEL || (sipmethod == SIP_INVITE && !ast_strlen_zero(p->options->auth))) { p->branch = p->invite_branch; build_via(p); } else if (newbranch) {