]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't have the Via header stored as a stringfield as it can change often during the...
authorJoshua Colp <jcolp@digium.com>
Mon, 16 Feb 2009 15:33:53 +0000 (15:33 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 16 Feb 2009 15:33:53 +0000 (15:33 +0000)
This issue crept up with subscriptions on the AA50. When an outgoing NOTIFY is sent a new branch value
is created and the Via header is changed to reflect it. Since this was a stringfield a new spot in the
pool was used for the value while the old was left untouched/unused. If the current pool was full a new
pool was created. This would cause memory usage to increase steadily.

(issue #AA50-2332)

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

channels/chan_sip.c

index acb0a2e900db96b8058803b67d64cdc9226ec59b..b3e239b02b7b90f4cdea1d4149c37ab1e618f6c0 100644 (file)
@@ -947,12 +947,12 @@ static struct sip_pvt {
                AST_STRING_FIELD(peermd5secret);
                AST_STRING_FIELD(cid_num);      /*!< Caller*ID number */
                AST_STRING_FIELD(cid_name);     /*!< Caller*ID name */
-               AST_STRING_FIELD(via);          /*!< Via: header */
                AST_STRING_FIELD(fullcontact);  /*!< The Contact: that the UA registers with us */
                AST_STRING_FIELD(our_contact);  /*!< Our contact header */
                AST_STRING_FIELD(rpid);         /*!< Our RPID header */
                AST_STRING_FIELD(rpid_from);    /*!< Our RPID From header */
        );
+       char via[128];                          /*!< Via: header */
        unsigned int ocseq;                     /*!< Current outgoing seqno */
        unsigned int icseq;                     /*!< Current incoming seqno */
        ast_group_t callgroup;                  /*!< Call group */
@@ -1823,8 +1823,8 @@ static void build_via(struct sip_pvt *p)
        const char *rport = ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_RFC3581 ? ";rport" : "";
 
        /* z9hG4bK is a magic cookie.  See RFC 3261 section 8.1.1.7 */
-       ast_string_field_build(p, via, "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x%s",
-                              ast_inet_ntoa(p->ourip), ourport, (int) p->branch, rport);
+       snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x%s",
+                ast_inet_ntoa(p->ourip), ourport, (int) p->branch, rport);
 }
 
 /*! \brief NAT fix - decide which IP address to use for ASterisk server?