[Pkg-voip-commits] [asterisk] 02/04: New upstream version 13.18.3~dfsg

Bernhard Schmidt berni at moszumanska.debian.org
Thu Dec 7 14:43:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

berni pushed a commit to branch master
in repository asterisk.

commit 1f23b1d65b15254b3eb6d2eb73c4321525a89860
Author: Bernhard Schmidt <berni at debian.org>
Date:   Thu Dec 7 15:19:57 2017 +0100

    New upstream version 13.18.3~dfsg
---
 .version                                           |   2 +-
 ChangeLog                                          | 100 +++++++++++++++++++++
 asterisk-13.18.1-summary.html                      |  24 -----
 asterisk-13.18.3-summary.html                      |  13 +++
 ...8.1-summary.txt => asterisk-13.18.3-summary.txt |  59 +++---------
 channels/chan_skinny.c                             |  11 +--
 res/res_pjsip/pjsip_configuration.c                |   4 +-
 res/res_pjsip_registrar.c                          |  58 ++++++++----
 8 files changed, 175 insertions(+), 96 deletions(-)

diff --git a/.version b/.version
index cb53e7f..b3deafe 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-13.18.1
\ No newline at end of file
+13.18.3
\ No newline at end of file
diff --git a/ChangeLog b/ChangeLog
index 158871e..f37f50a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,103 @@
+2017-12-01 19:42 +0000  Asterisk Development Team <asteriskteam at digium.com>
+
+	* asterisk 13.18.3 Released.
+
+2017-11-30 14:38 +0000 [65ca0785fa]  George Joseph <gjoseph at digium.com>
+
+	* AST-2017-013: chan_skinny: Call pthread_detach when sess threads end
+
+	  chan_skinny creates a new thread for each new session.  In trying
+	  to be a good cleanup citizen, the threads are joinable and the
+	  unload_module function does a pthread_cancel() and a pthread_join()
+	  on any sessions that are active at that time.  This has an
+	  unintended side effect though. Since you can call pthread_join on a
+	  thread that's already terminated, pthreads keeps the thread's
+	  storage around until you explicitly call pthread_join (or
+	  pthread_detach()).   Since only the module_unload function was
+	  calling pthread_join, and even then only on the ones active at the
+	  tme, the storage for every thread/session ever created sticks
+	  around until asterisk exits.
+
+	  * A thread can detach itself so the session_destroy() function
+	    now calls pthread_detach() just before it frees the session
+	    memory allocation.  The module_unload function still takes care
+	    of the ones that are still active should the module be unloaded.
+
+	  ASTERISK-27452
+	  Reported by: Juan Sacco
+
+	  Change-Id: I9af7268eba14bf76960566f891320f97b974e6dd
+
+2017-11-10 15:41 +0000  Asterisk Development Team <asteriskteam at digium.com>
+
+	* asterisk 13.18.2 Released.
+
+2017-11-01 11:12 +0000 [c3c75b729a]  Ben Ford <bford at digium.com>
+
+	* res_pjsip: Add to list of valid characters for from_user.
+
+	  Fixes a regression where some characters were unable to be used in
+	  the from_user field of an endpoint. Additionally, the backtick was
+	  removed from the list of valid characters, since it is not valid,
+	  and it was replaced with a single quote, which is a valid character.
+
+	  ASTERISK-27387
+
+	  Change-Id: Id80c10a644508365c87b3182e99ea49da11b0281
+	  (cherry picked from commit ffcb7e2a2540181ea41062ca0e1bc3e4fed9b3a5)
+
+2017-11-06 16:37 +0000 [f08a444eb3]  Richard Mudgett <rmudgett at digium.com>
+
+	* res_pjsip_registrar.c: Fix named AOR and pjproject group deadlock.
+
+	  One of the patches for ASTERISK_27147 introduced a deadlock regression.
+	  When the connection oriented transport shut down, the code attempted to
+	  remove the associated contact.  However, that same transport had just
+	  requested a registration that we hadn't responded to yet.  Depending
+	  upon timing we could deadlock.
+
+	  * Made send the REGISTER response after we completed processing the
+	  request contacts and released the named AOR lock to avoid the deadlock.
+
+	  ASTERISK-27391
+
+	  Change-Id: I89a90f87cb7a02facbafb44c75d8845f93417364
+
+2017-11-10 15:41 +0000  Asterisk Development Team <asteriskteam at digium.com>
+
+	* asterisk 13.18.2 Released.
+
+2017-11-01 11:12 +0000 [c3c75b729a]  Ben Ford <bford at digium.com>
+
+	* res_pjsip: Add to list of valid characters for from_user.
+
+	  Fixes a regression where some characters were unable to be used in
+	  the from_user field of an endpoint. Additionally, the backtick was
+	  removed from the list of valid characters, since it is not valid,
+	  and it was replaced with a single quote, which is a valid character.
+
+	  ASTERISK-27387
+
+	  Change-Id: Id80c10a644508365c87b3182e99ea49da11b0281
+	  (cherry picked from commit ffcb7e2a2540181ea41062ca0e1bc3e4fed9b3a5)
+
+2017-11-06 16:37 +0000 [f08a444eb3]  Richard Mudgett <rmudgett at digium.com>
+
+	* res_pjsip_registrar.c: Fix named AOR and pjproject group deadlock.
+
+	  One of the patches for ASTERISK_27147 introduced a deadlock regression.
+	  When the connection oriented transport shut down, the code attempted to
+	  remove the associated contact.  However, that same transport had just
+	  requested a registration that we hadn't responded to yet.  Depending
+	  upon timing we could deadlock.
+
+	  * Made send the REGISTER response after we completed processing the
+	  request contacts and released the named AOR lock to avoid the deadlock.
+
+	  ASTERISK-27391
+
+	  Change-Id: I89a90f87cb7a02facbafb44c75d8845f93417364
+
 2017-11-08 16:26 +0000  Asterisk Development Team <asteriskteam at digium.com>
 
 	* asterisk 13.18.1 Released.
diff --git a/asterisk-13.18.1-summary.html b/asterisk-13.18.1-summary.html
deleted file mode 100644
index a2f2e2c..0000000
--- a/asterisk-13.18.1-summary.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><title>Release Summary - asterisk-13.18.1</title><h1 align="center"><a name="top">Release Summary</a></h1><h3 align="center">asterisk-13.18.1</h3><h3 align="center">Date: 2017-11-08</h3><h3 align="center"><asteriskteam at digium.com></h3><hr><h2 align="center">Table of Contents</h2><ol>
-<li><a href="#summary">Summary</a></li>
-<li><a href="#contributors">Contributors</a></li>
-<li><a href="#closed_issues">Closed Issues</a></li>
-<li><a href="#diffstat">Diffstat</a></li>
-</ol><hr><a name="summary"><h2 align="center">Summary</h2></a><center><a href="#top">[Back to Top]</a></center><p>This release has been made to address one or more security vulnerabilities that have been identified. A security advisory document has been published for each vulnerability that includes additional information. Users of versions of Asterisk that are affected are strongly encouraged to review the advisories and determine what action they should take to protect their systems fr [...]
-<li><a href="http://downloads.asterisk.org/pub/security/AST-2017-009,AST-2017-010,AST-2017-011.html">AST-2017-009,AST-2017-010,AST-2017-011</a></li>
-</ul><p>The data in this summary reflects changes that have been made since the previous release, asterisk-13.18.0.</p><hr><a name="contributors"><h2 align="center">Contributors</h2></a><center><a href="#top">[Back to Top]</a></center><p>This table lists the people who have submitted code, those that have tested patches, as well as those that reported issues on the issue tracker that were resolved in this release. For coders, the number is how many of their patches (of any size) were com [...]
-<tr><th width="33%">Coders</th><th width="33%">Testers</th><th width="33%">Reporters</th></tr>
-<tr valign="top"><td width="33%">1 Richard Mudgett <rmudgett at digium.com><br/>1 Kevin Harwell <kharwell at digium.com><br/>1 George Joseph <gjoseph at digium.com><br/></td><td width="33%"><td width="33%">1 Youngsung Kim at LINE Corporation<br/>1 Richard Mudgett <rmudgett at digium.com><br/>1 Kim youngsung <youngsung.kim at linecorp.com><br/>1 Corey Farrell <git at cfware.com><br/></td></tr>
-</table><hr><a name="closed_issues"><h2 align="center">Closed Issues</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a list of all issues from the issue tracker that were closed by changes that went into this release.</p><h3>Bug</h3><h4>Category: General</h4><a href="https://issues.asterisk.org/jira/browse/ASTERISK-27319">ASTERISK-27319</a>: (Security) Function in PJSIP 2.7 miscalculates the length of an unsigned long variable in 64bit machines<br/>Reported by: Kim yo [...]
-<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=ed0acc1fff3547ee4d7870b45d9b910b328b4e8a">[ed0acc1fff]</a> George Joseph -- AST-2017-009: pjproject: Add validation of numeric header values</li>
-</ul><a href="https://issues.asterisk.org/jira/browse/ASTERISK-27337">ASTERISK-27337</a>: chan_sip: Security vulnerability with client code header (revisited)<br/>Reported by: Richard Mudgett<ul>
-<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=8f7073be6d08029d222de8a17c5982fa28534e58">[8f7073be6d]</a> Richard Mudgett -- AST-2017-010: Fix cdr_object_update_party_b_userfield_cb() buf overrun</li>
-</ul><br><h4>Category: Resources/res_pjsip</h4><a href="https://issues.asterisk.org/jira/browse/ASTERISK-27345">ASTERISK-27345</a>: res_pjsip_session: RTP instances leak on 488 responses.<br/>Reported by: Corey Farrell<ul>
-<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=cd7c10c6468c1931b4860d5eaf1b1b1df82fe72d">[cd7c10c646]</a> Kevin Harwell -- AST-2017-011 - res_pjsip_session: session leak when a call is rejected</li>
-</ul><br><h4>Category: Resources/res_pjsip_sdp_rtp</h4><a href="https://issues.asterisk.org/jira/browse/ASTERISK-27345">ASTERISK-27345</a>: res_pjsip_session: RTP instances leak on 488 responses.<br/>Reported by: Corey Farrell<ul>
-<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=cd7c10c6468c1931b4860d5eaf1b1b1df82fe72d">[cd7c10c646]</a> Kevin Harwell -- AST-2017-011 - res_pjsip_session: session leak when a call is rejected</li>
-</ul><br><h4>Category: Resources/res_pjsip_session</h4><a href="https://issues.asterisk.org/jira/browse/ASTERISK-27345">ASTERISK-27345</a>: res_pjsip_session: RTP instances leak on 488 responses.<br/>Reported by: Corey Farrell<ul>
-<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=cd7c10c6468c1931b4860d5eaf1b1b1df82fe72d">[cd7c10c646]</a> Kevin Harwell -- AST-2017-011 - res_pjsip_session: session leak when a call is rejected</li>
-</ul><br><hr><a name="diffstat"><h2 align="center">Diffstat Results</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a summary of the changes to the source code that went into this release that was generated using the diffstat utility.</p><pre>main/cdr.c                                                                                    |    6
-res/res_pjsip_session.c                                                                       |   80
-third-party/pjproject/patches/0090-sip_parser-Add-validity-checking-for-numeric-header-.patch |  828 ++++++++++
-3 files changed, 874 insertions(+), 40 deletions(-)</pre><br></html>
\ No newline at end of file
diff --git a/asterisk-13.18.3-summary.html b/asterisk-13.18.3-summary.html
new file mode 100644
index 0000000..af5ef42
--- /dev/null
+++ b/asterisk-13.18.3-summary.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><title>Release Summary - asterisk-13.18.3</title><h1 align="center"><a name="top">Release Summary</a></h1><h3 align="center">asterisk-13.18.3</h3><h3 align="center">Date: 2017-12-01</h3><h3 align="center"><asteriskteam at digium.com></h3><hr><h2 align="center">Table of Contents</h2><ol>
+<li><a href="#summary">Summary</a></li>
+<li><a href="#contributors">Contributors</a></li>
+<li><a href="#closed_issues">Closed Issues</a></li>
+<li><a href="#diffstat">Diffstat</a></li>
+</ol><hr><a name="summary"><h2 align="center">Summary</h2></a><center><a href="#top">[Back to Top]</a></center><p>This release has been made to address one or more security vulnerabilities that have been identified. A security advisory document has been published for each vulnerability that includes additional information. Users of versions of Asterisk that are affected are strongly encouraged to review the advisories and determine what action they should take to protect their systems fr [...]
+<li><a href="http://downloads.asterisk.org/pub/security/AST-2017-013.html">AST-2017-013</a></li>
+</ul><p>The data in this summary reflects changes that have been made since the previous release, asterisk-13.18.2.</p><hr><a name="contributors"><h2 align="center">Contributors</h2></a><center><a href="#top">[Back to Top]</a></center><p>This table lists the people who have submitted code, those that have tested patches, as well as those that reported issues on the issue tracker that were resolved in this release. For coders, the number is how many of their patches (of any size) were com [...]
+<tr><th width="33%">Coders</th><th width="33%">Testers</th><th width="33%">Reporters</th></tr>
+<tr valign="top"><td width="33%">1 George Joseph <gjoseph at digium.com><br/></td><td width="33%"><td width="33%">1 Juan Sacco<br/>1 George Joseph <gjoseph at digium.com><br/></td></tr>
+</table><hr><a name="closed_issues"><h2 align="center">Closed Issues</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a list of all issues from the issue tracker that were closed by changes that went into this release.</p><h3>Bug</h3><h4>Category: Channels/chan_skinny</h4><a href="https://issues.asterisk.org/jira/browse/ASTERISK-27452">ASTERISK-27452</a>: Security: chan_skinny:  Memory exhaustion if flooded with unauthenticated requests<br/>Reported by: George Joseph<ul>
+<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=65ca0785facae1dda45fffc9e6bc70ebcb2e5e08">[65ca0785fa]</a> George Joseph -- AST-2017-013: chan_skinny: Call pthread_detach when sess threads end</li>
+</ul><br><hr><a name="diffstat"><h2 align="center">Diffstat Results</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a summary of the changes to the source code that went into this release that was generated using the diffstat utility.</p><pre>0 files changed</pre><br></html>
\ No newline at end of file
diff --git a/asterisk-13.18.1-summary.txt b/asterisk-13.18.3-summary.txt
similarity index 50%
rename from asterisk-13.18.1-summary.txt
rename to asterisk-13.18.3-summary.txt
index af43cef..5f7ce9a 100644
--- a/asterisk-13.18.1-summary.txt
+++ b/asterisk-13.18.3-summary.txt
@@ -1,8 +1,8 @@
                                 Release Summary
 
-                                asterisk-13.18.1
+                                asterisk-13.18.3
 
-                                Date: 2017-11-08
+                                Date: 2017-12-01
 
                            <asteriskteam at digium.com>
 
@@ -30,10 +30,10 @@
 
    Security Advisories:
 
-     * AST-2017-009,AST-2017-010,AST-2017-011
+     * AST-2017-013
 
    The data in this summary reflects changes that have been made since the
-   previous release, asterisk-13.18.0.
+   previous release, asterisk-13.18.2.
 
      ----------------------------------------------------------------------
 
@@ -50,11 +50,9 @@
    issues that they reported that were affected by commits that went into
    this release.
 
-   Coders                   Testers       Reporters                           
-   1 Richard Mudgett                      1 Youngsung Kim at LINE Corporation 
-   1 Kevin Harwell                        1 Richard Mudgett                   
-   1 George Joseph                        1 Kim youngsung                     
-                                          1 Corey Farrell                     
+   Coders                   Testers                  Reporters                
+   1 George Joseph                                   1 Juan Sacco             
+                                                     1 George Joseph          
 
      ----------------------------------------------------------------------
 
@@ -67,39 +65,13 @@
 
   Bug
 
-    Category: General
+    Category: Channels/chan_skinny
 
-   ASTERISK-27319: (Security) Function in PJSIP 2.7 miscalculates the length
-   of an unsigned long variable in 64bit machines
-   Reported by: Kim youngsung
-     * [ed0acc1fff] George Joseph -- AST-2017-009: pjproject: Add validation
-       of numeric header values
-   ASTERISK-27337: chan_sip: Security vulnerability with client code header
-   (revisited)
-   Reported by: Richard Mudgett
-     * [8f7073be6d] Richard Mudgett -- AST-2017-010: Fix
-       cdr_object_update_party_b_userfield_cb() buf overrun
-
-    Category: Resources/res_pjsip
-
-   ASTERISK-27345: res_pjsip_session: RTP instances leak on 488 responses.
-   Reported by: Corey Farrell
-     * [cd7c10c646] Kevin Harwell -- AST-2017-011 - res_pjsip_session:
-       session leak when a call is rejected
-
-    Category: Resources/res_pjsip_sdp_rtp
-
-   ASTERISK-27345: res_pjsip_session: RTP instances leak on 488 responses.
-   Reported by: Corey Farrell
-     * [cd7c10c646] Kevin Harwell -- AST-2017-011 - res_pjsip_session:
-       session leak when a call is rejected
-
-    Category: Resources/res_pjsip_session
-
-   ASTERISK-27345: res_pjsip_session: RTP instances leak on 488 responses.
-   Reported by: Corey Farrell
-     * [cd7c10c646] Kevin Harwell -- AST-2017-011 - res_pjsip_session:
-       session leak when a call is rejected
+   ASTERISK-27452: Security: chan_skinny: Memory exhaustion if flooded with
+   unauthenticated requests
+   Reported by: George Joseph
+     * [65ca0785fa] George Joseph -- AST-2017-013: chan_skinny: Call
+       pthread_detach when sess threads end
 
      ----------------------------------------------------------------------
 
@@ -110,7 +82,4 @@
    This is a summary of the changes to the source code that went into this
    release that was generated using the diffstat utility.
 
- main/cdr.c                                                                                    |    6
- res/res_pjsip_session.c                                                                       |   80
- third-party/pjproject/patches/0090-sip_parser-Add-validity-checking-for-numeric-header-.patch |  828 ++++++++++
- 3 files changed, 874 insertions(+), 40 deletions(-)
+ 0 files changed
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index ad7351d..ccf6a94 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -7429,6 +7429,11 @@ static void destroy_session(struct skinnysession *s)
 	}
 	ast_mutex_unlock(&s->lock);
 	ast_mutex_destroy(&s->lock);
+
+	if (s->t != AST_PTHREADT_NULL) {
+		pthread_detach(s->t);
+	}
+
 	ast_free(s);
 }
 
@@ -7515,11 +7520,6 @@ static void *skinny_session(void *data)
 	int eventmessage = 0;
 	struct pollfd fds[1];
 
-	if (!s) {
-		ast_log(LOG_WARNING, "Bad Skinny Session\n");
-		return 0;
-	}
-
 	ast_log(LOG_NOTICE, "Starting Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr));
 
 	pthread_cleanup_push(skinny_session_cleanup, s);
@@ -7685,6 +7685,7 @@ static void *accept_thread(void *ignore)
 		s->keepalive_timeout_sched = -1;
 
 		if (ast_pthread_create(&s->t, NULL, skinny_session, s)) {
+			s->t = AST_PTHREADT_NULL;
 			destroy_session(s);
 		}
 	}
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 8106676..fa54448 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1137,11 +1137,11 @@ static int from_user_handler(const struct aco_option *opt,
 {
 	struct ast_sip_endpoint *endpoint = obj;
 	/* Valid non-alphanumeric characters for URI */
-	char *valid_uri_marks = "-_.!~*`()";
+	char *valid_uri_marks = "-._~%!$&'()*+,;=:";
 	const char *val;
 
 	for (val = var->value; *val; val++) {
-		if (!strchr(valid_uri_marks, *val) && !isdigit(*val) && !isalpha(*val)) {
+		if (!isalpha(*val) && !isdigit(*val) && !strchr(valid_uri_marks, *val)) {
 			ast_log(LOG_ERROR, "Error configuring endpoint '%s' - '%s' field "
 			"contains invalid character '%c'\n",
 			ast_sorcery_object_get_id(endpoint), var->name, *val);
diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c
index 8ba8597..cdf045f 100644
--- a/res/res_pjsip_registrar.c
+++ b/res/res_pjsip_registrar.c
@@ -447,11 +447,19 @@ static void remove_excess_contacts(struct ao2_container *contacts, unsigned int
 	AST_VECTOR_FREE(&contact_vec);
 }
 
-static int register_aor_core(pjsip_rx_data *rdata,
+struct aor_core_response {
+	/*! Tx data to use for statefull response.  NULL for stateless response. */
+	pjsip_tx_data *tdata;
+	/*! SIP response code to send in stateless response */
+	int code;
+};
+
+static void register_aor_core(pjsip_rx_data *rdata,
 	struct ast_sip_endpoint *endpoint,
 	struct ast_sip_aor *aor,
 	const char *aor_name,
-	struct ao2_container *contacts)
+	struct ao2_container *contacts,
+	struct aor_core_response *response)
 {
 	static const pj_str_t USER_AGENT = { "User-Agent", 10 };
 
@@ -480,19 +488,19 @@ static int register_aor_core(pjsip_rx_data *rdata,
 
 	if (registrar_validate_contacts(rdata, contacts, aor, &added, &updated, &deleted)) {
 		/* The provided Contact headers do not conform to the specification */
-		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 400, NULL, NULL, NULL);
 		ast_sip_report_failed_acl(endpoint, rdata, "registrar_invalid_contacts_provided");
 		ast_log(LOG_WARNING, "Failed to validate contacts in REGISTER request from '%s'\n",
 				ast_sorcery_object_get_id(endpoint));
-		return PJ_TRUE;
+		response->code = 400;
+		return;
 	}
 
 	if (registrar_validate_path(rdata, aor, &path_str)) {
 		/* Ensure that intervening proxies did not make invalid modifications to the request */
-		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 420, NULL, NULL, NULL);
 		ast_log(LOG_WARNING, "Invalid modifications made to REGISTER request from '%s' by intervening proxy\n",
 				ast_sorcery_object_get_id(endpoint));
-		return PJ_TRUE;
+		response->code = 420;
+		return;
 	}
 
 	if (aor->remove_existing) {
@@ -504,18 +512,18 @@ static int register_aor_core(pjsip_rx_data *rdata,
 	}
 	if (contact_count > aor->max_contacts) {
 		/* Enforce the maximum number of contacts */
-		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 403, NULL, NULL, NULL);
 		ast_sip_report_failed_acl(endpoint, rdata, "registrar_attempt_exceeds_maximum_configured_contacts");
 		ast_log(LOG_WARNING, "Registration attempt from endpoint '%s' to AOR '%s' will exceed max contacts of %u\n",
 				ast_sorcery_object_get_id(endpoint), aor_name, aor->max_contacts);
-		return PJ_TRUE;
+		response->code = 403;
+		return;
 	}
 
 	details.pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(),
 		"Contact Comparison", 256, 256);
 	if (!details.pool) {
-		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
-		return PJ_TRUE;
+		response->code = 500;
+		return;
 	}
 
 	user_agent_hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &USER_AGENT, NULL);
@@ -730,8 +738,8 @@ static int register_aor_core(pjsip_rx_data *rdata,
 	/* Re-retrieve contacts.  Caller will clean up the original container. */
 	contacts = ast_sip_location_retrieve_aor_contacts_nolock(aor);
 	if (!contacts) {
-		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
-		return PJ_TRUE;
+		response->code = 500;
+		return;
 	}
 	response_contact = ao2_callback(contacts, 0, NULL, NULL);
 
@@ -739,7 +747,8 @@ static int register_aor_core(pjsip_rx_data *rdata,
 	if (ast_sip_create_response(rdata, 200, response_contact, &tdata) != PJ_SUCCESS) {
 		ao2_cleanup(response_contact);
 		ao2_cleanup(contacts);
-		return PJ_TRUE;
+		response->code = 500;
+		return;
 	}
 	ao2_cleanup(response_contact);
 
@@ -754,9 +763,7 @@ static int register_aor_core(pjsip_rx_data *rdata,
 		pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)expires_hdr);
 	}
 
-	ast_sip_send_stateful_response(rdata, tdata, endpoint);
-
-	return PJ_TRUE;
+	response->tdata = tdata;
 }
 
 static int register_aor(pjsip_rx_data *rdata,
@@ -764,12 +771,16 @@ static int register_aor(pjsip_rx_data *rdata,
 	struct ast_sip_aor *aor,
 	const char *aor_name)
 {
-	int res;
+	struct aor_core_response response = {
+		.code = 500,
+	};
 	struct ao2_container *contacts = NULL;
 	struct ast_named_lock *lock;
 
 	lock = ast_named_lock_get(AST_NAMED_LOCK_TYPE_MUTEX, "aor", aor_name);
 	if (!lock) {
+		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(),
+			rdata, response.code, NULL, NULL, NULL);
 		return PJ_TRUE;
 	}
 
@@ -778,15 +789,24 @@ static int register_aor(pjsip_rx_data *rdata,
 	if (!contacts) {
 		ao2_unlock(lock);
 		ast_named_lock_put(lock);
+		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(),
+			rdata, response.code, NULL, NULL, NULL);
 		return PJ_TRUE;
 	}
 
-	res = register_aor_core(rdata, endpoint, aor, aor_name, contacts);
+	register_aor_core(rdata, endpoint, aor, aor_name, contacts, &response);
 	ao2_cleanup(contacts);
 	ao2_unlock(lock);
 	ast_named_lock_put(lock);
 
-	return res;
+	/* Now send the REGISTER response to the peer */
+	if (response.tdata) {
+		ast_sip_send_stateful_response(rdata, response.tdata, endpoint);
+	} else {
+		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(),
+			rdata, response.code, NULL, NULL, NULL);
+	}
+	return PJ_TRUE;
 }
 
 static int match_aor(const char *aor_name, const char *id)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/asterisk.git



More information about the Pkg-voip-commits mailing list