[asterisk-commits] jrose: branch 10 r351560 - in /branches/10: ./ channels/ include/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 19 15:47:26 CST 2012


Author: jrose
Date: Thu Jan 19 15:47:22 2012
New Revision: 351560

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=351560
Log:
Eliminates doubling the :port part of SIP Notify Message-Account headers.

This patch prevents the domain string from getting mangled during the initreqprep
step by moving the initialization to before its immediate use.  It also documents
this pitfall for the ast_sockaddr_stringify functions.

(issue ASTERISK-19057)
Reported by: Yuri
Review: https://reviewboard.asterisk.org/r/1678/
........

Merged revisions 351559 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/channels/chan_sip.c
    branches/10/include/asterisk/netsock2.h

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/chan_sip.c?view=diff&rev=351560&r1=351559&r2=351560
==============================================================================
--- branches/10/channels/chan_sip.c (original)
+++ branches/10/channels/chan_sip.c Thu Jan 19 15:47:22 2012
@@ -12959,7 +12959,7 @@
 	struct sip_request req;
 	struct ast_str *out = ast_str_alloca(500);
 	int ourport = (p->fromdomainport) ? p->fromdomainport : ast_sockaddr_port(&p->ourip);
-	const char *domain = S_OR(p->fromdomain, ast_sockaddr_stringify_host_remote(&p->ourip));
+	const char *domain;
 	const char *exten = S_OR(vmexten, default_vmexten);
 
 	initreqprep(&req, p, SIP_NOTIFY, NULL);
@@ -12967,6 +12967,8 @@
 	add_header(&req, "Content-Type", default_notifymime);
 	ast_str_append(&out, 0, "Messages-Waiting: %s\r\n", newmsgs ? "yes" : "no");
 
+	/* domain initialization occurs here because initreqprep changes ast_sockaddr_stringify string. */
+	domain = S_OR(p->fromdomain, ast_sockaddr_stringify_host_remote(&p->ourip));
 
 	if (!sip_standard_port(p->socket.type, ourport)) {
 		if (p->socket.type == SIP_TRANSPORT_UDP) {

Modified: branches/10/include/asterisk/netsock2.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/include/asterisk/netsock2.h?view=diff&rev=351560&r1=351559&r2=351560
==============================================================================
--- branches/10/include/asterisk/netsock2.h (original)
+++ branches/10/include/asterisk/netsock2.h Thu Jan 19 15:47:22 2012
@@ -185,6 +185,14 @@
  *    a.b.c.d for IPv4
  *    [a:b:c:...:d] for IPv6.
  * AST_SOCKADDR_STR_PORT: port only
+ *
+ * \note The string pointer returned by this function will point to a string that
+ * will be changed whenever any form of ast_sockaddr_stringify_fmt is called on that
+ * thread. Because of this, it is important that if you use this function, you use the
+ * string before another use of this function is made elsewhere in the same thread.
+ * The easiest way to accomplish this is by immediately copying the string to a buffer
+ * with something like ast_strdupa.
+ *
  * \retval "(null)" \a addr is null
  * \retval "" An error occurred during processing
  * \retval string The stringified form of the address




More information about the asterisk-commits mailing list