[asterisk-commits] mmichelson: branch mmichelson/sip_transfer r388307 - /team/mmichelson/sip_tra...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 10 09:35:42 CDT 2013


Author: mmichelson
Date: Fri May 10 09:35:40 2013
New Revision: 388307

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388307
Log:
Address Josh's comment about not using SIPBUFSIZE if possible.

Use an ast_str now to create the replaces string.


Modified:
    team/mmichelson/sip_transfer/channels/chan_sip.c

Modified: team/mmichelson/sip_transfer/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_transfer/channels/chan_sip.c?view=diff&rev=388307&r1=388306&r2=388307
==============================================================================
--- team/mmichelson/sip_transfer/channels/chan_sip.c (original)
+++ team/mmichelson/sip_transfer/channels/chan_sip.c Fri May 10 09:35:40 2013
@@ -26233,7 +26233,7 @@
 	/*! Domain of the URI in the REFER's Refer-To header */
 	const char *domain;
 	/*! Contents of what to place in a Replaces header of an INVITE */
-	char replaces[SIPBUFSIZE];
+	const char *replaces;
 	/*! Redirecting information to set on the channel */
 	struct ast_party_redirecting redirecting;
 	/*! Parts of the redirecting structure that are to be updated */
@@ -26333,6 +26333,7 @@
 	struct blind_transfer_cb_data cb_data;
 	enum ast_transfer_result transfer_res;
 	RAII_VAR(struct ast_channel *, transferer, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_str *, replaces_str, NULL, ast_free_ptr);
 
 	if (req->debug) {
 		ast_verbose("Call %s got a SIP call transfer from %s: (REFER)!\n",
@@ -26451,6 +26452,7 @@
 	if (p->refer->attendedtransfer) {
 		/* both p and p->owner _MUST_ be locked while calling local_attended_transfer */
 		if ((res = local_attended_transfer(p, NULL, req, seqno, nounlock))) {
+			ast_clear_flag(&p->flags[0], SIP_GOTREFER);
 			return res;
 		}
 		/* Fall through for remote transfers that we did not find locally */
@@ -26472,13 +26474,21 @@
 	cb_data.referred_by = ast_strdupa(p->refer->referred_by);
 
 	if (!ast_strlen_zero(p->refer->replaces_callid)) {
-		snprintf(cb_data.replaces, sizeof(cb_data.replaces), "%s%s%s%s%s", p->refer->replaces_callid,
+		replaces_str = ast_str_create(128);
+		if (!replaces_str) {
+			ast_log(LOG_NOTICE, "Unable to create Replaces string for remote attended transfer. Transfer failed\n");
+			ast_clear_flag(&p->flags[0], SIP_GOTREFER);
+			ast_party_redirecting_free(&cb_data.redirecting);
+			return -1;
+		}
+		ast_str_append(&replaces_str, 0, "%s%s%s%s%s", p->refer->replaces_callid,
 				!ast_strlen_zero(p->refer->replaces_callid_totag) ? ";to-tag=" : "",
 				S_OR(p->refer->replaces_callid_totag, ""),
 				!ast_strlen_zero(p->refer->replaces_callid_fromtag) ? ";from-tag=" : "",
 				S_OR(p->refer->replaces_callid_fromtag, ""));
+		cb_data.replaces = ast_str_buffer(replaces_str);
 	} else {
-		cb_data.replaces[0] = '\0';
+		cb_data.replaces = NULL;
 	}
 
 	if (!*nounlock) {




More information about the asterisk-commits mailing list