[asterisk-commits] jrose: trunk r351561 - in /trunk: ./ channels/ include/asterisk/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 19 15:55:47 CST 2012
Author: jrose
Date: Thu Jan 19 15:55:41 2012
New Revision: 351561
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=351561
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
........
Merged revisions 351560 from http://svn.asterisk.org/svn/asterisk/branches/10
Modified:
trunk/ (props changed)
trunk/channels/chan_sip.c
trunk/include/asterisk/netsock2.h
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.
Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=351561&r1=351560&r2=351561
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Jan 19 15:55:41 2012
@@ -12994,7 +12994,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);
@@ -13002,6 +13002,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: trunk/include/asterisk/netsock2.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/netsock2.h?view=diff&rev=351561&r1=351560&r2=351561
==============================================================================
--- trunk/include/asterisk/netsock2.h (original)
+++ trunk/include/asterisk/netsock2.h Thu Jan 19 15:55:41 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