]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
via-header branches not updated correctly on INVITE
authorDavid Vossel <dvossel@digium.com>
Fri, 18 Sep 2009 16:19:15 +0000 (16:19 +0000)
committerDavid Vossel <dvossel@digium.com>
Fri, 18 Sep 2009 16:19:15 +0000 (16:19 +0000)
INVITE requests must always contain a new unique branch id. When
a new branch id is created for an INVITE, the dialog's invite_branch
variable must be updated so CANCEL requests use the correct branch id.

(closes issue #15262)
Reported by: maniax
Patches:
      asterisk-1.6.1.0-sip-branch.patch uploaded by tweety (license 608)
      invite_new_branch_trunk.diff uploaded by dvossel (license 671)
Tested by: maniax, dvossel

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@219450 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 9cc4cc2835500f0bc68b21ba6c44473aabfe113e..d8a553e4da820cfa1e3f0a8a15de1721292584f9 100644 (file)
@@ -6316,13 +6316,14 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, in
                seqno = p->ocseq;
        }
        
-       /* 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 && p->options && !ast_strlen_zero(p->options->auth))) {
+       /* A CANCEL must have the same branch as the INVITE that it is canceling. */
+       if (sipmethod == SIP_CANCEL) {
                p->branch = p->invite_branch;
                build_via(p);
+       } else if (newbranch && (sipmethod == SIP_INVITE)) {
+               p->branch ^= ast_random();
+               p->invite_branch = p->branch;
+               build_via(p);
        } else if (newbranch) {
                p->branch ^= ast_random();
                build_via(p);