res_pjproject.c: Upgrade bundled PJPROJECT to 2.7

Update patches included in bundled PJPROJECT for the new version.

ASTERISK-27355

Change-Id: I9ac5dbbffaadca25ad24fac8b9ab615e5ace6083
This commit is contained in:
Richard Mudgett 2017-10-17 10:53:52 -05:00
parent 4760b2445c
commit e41561fc2a
18 changed files with 55 additions and 977 deletions

View File

@ -1,3 +1,11 @@
# We switched download locations so Asterisk users don't bombard the Teluu
# site with download requests.
#
# For future reference when upgrading bundled PJPROJECT the next time
# PJPROJECT is released.
# Teluu's download URL.
# PJPROJECT_URL ?= http://www.pjsip.org/release/$(PJPROJECT_VERSION)
PJPROJECT_URL ?= https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/$(PJPROJECT_VERSION)
# PJPROJECT_CONFIGURE_OPTS could come from the command line or could be

View File

@ -1,21 +1,28 @@
From 1ec66eb253c603e06fedff5710e701dc0e55c697 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Thu, 23 Feb 2017 17:10:07 -0600
Subject: [PATCH 1/3] 0000-remove-third-party.patch
---
build.mak.in | 107 -----------------------------------------------------------
1 file changed, 107 deletions(-)
diff --git a/build.mak.in b/build.mak.in
index eb28663..83024ef 100644
index 6c263a9..36e7ff4 100644
--- a/build.mak.in
+++ b/build.mak.in
@@ -1,6 +1,5 @@
@@ -1,4 +1,3 @@
-export PJDIR := @ac_pjdir@
include $(PJDIR)/version.mak
export PJ_DIR := $(PJDIR)
# @configure_input@
export MACHINE_NAME := auto
@@ -28,19 +27,6 @@ export APP_THIRD_PARTY_EXT :=
export APP_THIRD_PARTY_LIBS :=
export APP_THIRD_PARTY_LIB_FILES :=
-ifeq (@ac_external_srtp@,1)
-ifneq (@ac_external_srtp@,0)
-# External SRTP library
-APP_THIRD_PARTY_EXT += -lsrtp
-APP_THIRD_PARTY_EXT += -l@ac_external_srtp_lib@
-else
-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libsrtp-$(LIB_SUFFIX)
-ifeq ($(PJ_SHARED_LIBRARIES),)
@ -129,3 +136,6 @@ index eb28663..83024ef 100644
# Additional flags
@ac_build_mak_vars@
--
2.7.4

View File

@ -1,3 +1,14 @@
From 34f25c67f17be80814ddb16edc6c76d30213ca1b Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Thu, 23 Feb 2017 17:11:00 -0600
Subject: [PATCH 2/3] 0000-set_apps_initial_log_level.patch
---
pjsip-apps/src/pjsua/main.c | 2 ++
pjsip-apps/src/pjsystest/main_console.c | 2 ++
pjsip-apps/src/python/_pjsua.c | 3 ++-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/pjsip-apps/src/pjsua/main.c b/pjsip-apps/src/pjsua/main.c
index 2baaf82..11831f2 100644
--- a/pjsip-apps/src/pjsua/main.c
@ -37,3 +48,6 @@ index fb80e23..c9b21d8 100644
PyEval_InitThreads();
if (PyType_Ready(&PyTyp_pjsua_callback) < 0)
--
2.7.4

View File

@ -1,84 +0,0 @@
From b7af9e6639f29feb4db6d0866c98e552b025ec96 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Mon, 6 Feb 2017 15:39:29 -0700
Subject: [PATCH] evsub: Add pjsip_evsub_set_uas_timeout.
A UAS which needs to recreate incoming subscriptions from a persistent
store can call pjsip_dlg_create_uas_and_inc_lock and
pjsip_evsub_create_uas as long as they've persisted the
correct data but since the timer is triggered by an incoming subscribe,
it's never set and the subscription never expires.
* Add pjsip_evsub_set_uas_timeout which is just a wrapper around
evsub.c:set_timeout(sub, TIMER_TYPE_UAS_TIMEOUT, seconds)
* Also, fixed copy-paste error in pjsip_sub_state_hdr_print when
printing retry-after parameter.
---
pjsip/include/pjsip-simple/evsub.h | 14 ++++++++++++++
pjsip/src/pjsip-simple/evsub.c | 10 ++++++++++
pjsip/src/pjsip-simple/evsub_msg.c | 2 +-
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/pjsip/include/pjsip-simple/evsub.h b/pjsip/include/pjsip-simple/evsub.h
index 82e0a7c..45e6411 100644
--- a/pjsip/include/pjsip-simple/evsub.h
+++ b/pjsip/include/pjsip-simple/evsub.h
@@ -511,6 +511,20 @@ PJ_DEF(pj_status_t) pjsip_evsub_add_ref(pjsip_evsub *sub);
PJ_DEF(pj_status_t) pjsip_evsub_dec_ref(pjsip_evsub *sub);
+/**
+ * Sets, resets or cancels the UAS subscription timeout.
+ *
+ * If there is an existing timer, it is cancelled before any
+ * other action.
+ *
+ * A timeout of 0 is ignored except that any existing timer
+ * is cancelled.
+ *
+ * @param sub The server subscription instance.
+ * @param seconds The new timeout.
+ */
+PJ_DEF(void) pjsip_evsub_set_uas_timeout(pjsip_evsub *sub, pj_int32_t seconds);
+
PJ_END_DECL
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index 3fe4b49..6918a8c 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -530,6 +530,16 @@ static void set_timer( pjsip_evsub *sub, int timer_id,
/*
+ * Set event subscription UAS timout.
+ */
+PJ_DEF(void) pjsip_evsub_set_uas_timeout(pjsip_evsub *sub, pj_int32_t seconds)
+{
+ PJ_ASSERT_RETURN(sub != NULL, PJ_EINVAL);
+ set_timer(sub, TIMER_TYPE_UAS_TIMEOUT, seconds);
+}
+
+
+/*
* Destructor.
*/
static void evsub_on_destroy(void *obj)
diff --git a/pjsip/src/pjsip-simple/evsub_msg.c b/pjsip/src/pjsip-simple/evsub_msg.c
index b44a715..b37db1c 100644
--- a/pjsip/src/pjsip-simple/evsub_msg.c
+++ b/pjsip/src/pjsip-simple/evsub_msg.c
@@ -179,7 +179,7 @@ static int pjsip_sub_state_hdr_print(pjsip_sub_state_hdr *hdr,
}
if (hdr->retry_after >= 0) {
pj_memcpy(p, ";retry-after=", 13);
- p += 9;
+ p += 13;
printed = pj_utoa(hdr->retry_after, p);
p += printed;
}
--
2.9.3

View File

@ -1,7 +1,10 @@
From 28490e9ddee0937516f9edcaf95d274fe5ceaf4c Mon Sep 17 00:00:00 2001
From: Sean Bright <sean.bright@gmail.com>
Date: Mon, 25 Sep 2017 14:06:53 -0400
Subject: [PATCH] ICE: Use STUN FINGERPRINT attribute when sending keepalives
From 06bc834969a34d2c60e05beed3051b4a6d34c125 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Thu, 28 Sep 2017 10:57:23 -0500
Subject: [PATCH 3/3] r5665 svn backport ICE: Use STUN FINGERPRINT attribute
when sending keepalives
Fixed #2046: ICE: Use STUN FINGERPRINT attribute when sending keepalives
Per RFC 5245 Section 10:
@ -10,22 +13,25 @@ Per RFC 5245 Section 10:
mechanism. It SHOULD contain the FINGERPRINT attribute to aid in
demultiplexing, but SHOULD NOT contain any other attributes.
---
pjnath/src/pjnath/ice_session.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
pjnath/src/pjnath/ice_session.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c
index 159d7b1..f90005a 100644
index 27a2950..63a0d1c 100644
--- a/pjnath/src/pjnath/ice_session.c
+++ b/pjnath/src/pjnath/ice_session.c
@@ -1217,10 +1217,8 @@ static void ice_keep_alive(pj_ice_sess *ice, pj_bool_t send_now)
@@ -1217,10 +1217,12 @@ static void ice_keep_alive(pj_ice_sess *ice, pj_bool_t send_now)
msg_data = PJ_POOL_ZALLOC_T(tdata->pool, pj_ice_msg_data);
msg_data->transport_id = the_check->lcand->transport_id;
- /* Temporarily disable FINGERPRINT. The Binding Indication
- * SHOULD NOT contain any attributes.
- */
+ /* RFC 5245 Section 10:
+ * The Binding Indication SHOULD contain the FINGERPRINT attribute
+ * to aid in demultiplexing, but SHOULD NOT contain any other
+ * attributes.
*/
- saved = pj_stun_session_use_fingerprint(comp->stun_sess, PJ_FALSE);
+ /* Make sure that the FINGERPRINT attribute is used per RFC 5245 Section 10 */
+ saved = pj_stun_session_use_fingerprint(comp->stun_sess, PJ_TRUE);
/* Send to session */

View File

@ -1,77 +0,0 @@
From df1ceb301c8a17969c467e3cf00246cfc28d1732 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Mon, 20 Feb 2017 12:19:05 -0600
Subject: [PATCH 1/5] r5554 svn backport Increase SENDER_WIDTH column size for
64-bit systems.
Re #1994 (misc): Make the log's sender and thread width a compile-time configurable setting.
Thanks to Richard Mudgett for the suggestion.
---
pjlib/include/pj/config.h | 27 +++++++++++++++++++++++++++
pjlib/src/pj/log.c | 4 ++--
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/pjlib/include/pj/config.h b/pjlib/include/pj/config.h
index 079d69b..3523f50 100644
--- a/pjlib/include/pj/config.h
+++ b/pjlib/include/pj/config.h
@@ -442,6 +442,33 @@
#endif
/**
+ * Log sender width.
+ *
+ * Default: 22 (for 64-bit machines), 14 otherwise
+ */
+#ifndef PJ_LOG_SENDER_WIDTH
+# if PJ_HAS_STDINT_H
+# include <stdint.h>
+# if (UINTPTR_MAX == 0xffffffffffffffff)
+# define PJ_LOG_SENDER_WIDTH 22
+# else
+# define PJ_LOG_SENDER_WIDTH 14
+# endif
+# else
+# define PJ_LOG_SENDER_WIDTH 14
+# endif
+#endif
+
+/**
+ * Log thread name width.
+ *
+ * Default: 12
+ */
+#ifndef PJ_LOG_THREAD_WIDTH
+# define PJ_LOG_THREAD_WIDTH 12
+#endif
+
+/**
* Colorfull terminal (for logging etc).
*
* Default: 1
diff --git a/pjlib/src/pj/log.c b/pjlib/src/pj/log.c
index 293ad46..cf7ac37 100644
--- a/pjlib/src/pj/log.c
+++ b/pjlib/src/pj/log.c
@@ -380,7 +380,7 @@ PJ_DEF(void) pj_log( const char *sender, int level,
pre += pj_utoa_pad(ptime.msec, pre, 3, '0');
}
if (log_decor & PJ_LOG_HAS_SENDER) {
- enum { SENDER_WIDTH = 14 };
+ enum { SENDER_WIDTH = PJ_LOG_SENDER_WIDTH };
pj_size_t sender_len = strlen(sender);
if (pre!=log_buffer) *pre++ = ' ';
if (sender_len <= SENDER_WIDTH) {
@@ -395,7 +395,7 @@ PJ_DEF(void) pj_log( const char *sender, int level,
}
}
if (log_decor & PJ_LOG_HAS_THREAD_ID) {
- enum { THREAD_WIDTH = 12 };
+ enum { THREAD_WIDTH = PJ_LOG_THREAD_WIDTH };
const char *thread_name = pj_thread_get_name(pj_thread_this());
pj_size_t thread_len = strlen(thread_name);
*pre++ = ' ';
--
2.7.4

View File

@ -1,112 +0,0 @@
From d9d52f005f6d0242ea84e7c59ad6b25f052c8485 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Mon, 20 Feb 2017 12:05:32 -0600
Subject: [PATCH 3/5] r5559 svn backport Fix to resolve DNS SRV crashes.
Re #1994 (misc): Don't try to resolve a DNS SRV query that is already considered resolved.
Thanks to Richard Mudgett for the patch.
srv_resolver.c: Don't try to send query if already considered resolved.
* In resolve_hostnames() don't try to resolve a query that is already
considered resolved.
* In resolve_hostnames() fix DNS typo in comments.
* In build_server_entries() move a common expression assigning to cnt
earlier.
sip_transport.c: Fix tdata object name to actually contain the pointer.
It helps if the logs referencing a tdata object buffer actually have
a name that includes the correct pointer as part of the name. Also
since the tdata has its own pool it helps if any logs referencing the
pool have the same name as the tdata object. This change brings tdata
logging in line with how tsx objects are named.
---
pjlib-util/src/pjlib-util/srv_resolver.c | 18 +++++++++++++-----
pjsip/src/pjsip/sip_transport.c | 3 ++-
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/pjlib-util/src/pjlib-util/srv_resolver.c b/pjlib-util/src/pjlib-util/srv_resolver.c
index 8a2f7e1..84ad3f6 100644
--- a/pjlib-util/src/pjlib-util/srv_resolver.c
+++ b/pjlib-util/src/pjlib-util/srv_resolver.c
@@ -407,8 +407,9 @@ static void build_server_entries(pj_dns_srv_async_query *query_job,
for (i=0; i<query_job->srv_cnt; ++i) {
pj_in_addr addr;
pj_in6_addr addr6;
+ unsigned cnt = query_job->srv[i].addr_cnt;
- if (query_job->srv[i].addr_cnt != 0) {
+ if (cnt != 0) {
/* IP address already resolved */
continue;
}
@@ -417,7 +418,6 @@ static void build_server_entries(pj_dns_srv_async_query *query_job,
pj_inet_pton(pj_AF_INET(), &query_job->srv[i].target_name,
&addr) == PJ_SUCCESS)
{
- unsigned cnt = query_job->srv[i].addr_cnt;
pj_sockaddr_init(pj_AF_INET(), &query_job->srv[i].addr[cnt],
NULL, query_job->srv[i].port);
query_job->srv[i].addr[cnt].ipv4.sin_addr = addr;
@@ -427,7 +427,6 @@ static void build_server_entries(pj_dns_srv_async_query *query_job,
pj_inet_pton(pj_AF_INET6(), &query_job->srv[i].target_name,
&addr6) == PJ_SUCCESS)
{
- unsigned cnt = query_job->srv[i].addr_cnt;
pj_sockaddr_init(pj_AF_INET6(), &query_job->srv[i].addr[cnt],
NULL, query_job->srv[i].port);
query_job->srv[i].addr[cnt].ipv6.sin6_addr = addr6;
@@ -480,6 +479,15 @@ static pj_status_t resolve_hostnames(pj_dns_srv_async_query *query_job)
for (i=0; i<query_job->srv_cnt; ++i) {
struct srv_target *srv = &query_job->srv[i];
+ if (srv->addr_cnt != 0) {
+ /*
+ * This query is already counted as resolved because of the
+ * additional records in the SRV response or the target name
+ * is an IP address exception in build_server_entries().
+ */
+ continue;
+ }
+
PJ_LOG(5, (query_job->objname,
"Starting async DNS A query_job for %.*s",
(int)srv->target_name.slen,
@@ -493,7 +501,7 @@ static pj_status_t resolve_hostnames(pj_dns_srv_async_query *query_job)
status = PJ_SUCCESS;
- /* Start DNA A record query */
+ /* Start DNS A record query */
if ((query_job->option & PJ_DNS_SRV_RESOLVE_AAAA_ONLY) == 0)
{
if ((query_job->option & PJ_DNS_SRV_RESOLVE_AAAA) != 0) {
@@ -511,7 +519,7 @@ static pj_status_t resolve_hostnames(pj_dns_srv_async_query *query_job)
&srv->common, &srv->q_a);
}
- /* Start DNA AAAA record query */
+ /* Start DNS AAAA record query */
if (status == PJ_SUCCESS &&
(query_job->option & PJ_DNS_SRV_RESOLVE_AAAA) != 0)
{
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index d672a6d..6dd14d1 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -422,7 +422,8 @@ PJ_DEF(pj_status_t) pjsip_tx_data_create( pjsip_tpmgr *mgr,
tdata = PJ_POOL_ZALLOC_T(pool, pjsip_tx_data);
tdata->pool = pool;
tdata->mgr = mgr;
- pj_memcpy(tdata->obj_name, pool->obj_name, PJ_MAX_OBJ_NAME);
+ pj_ansi_snprintf(tdata->obj_name, sizeof(tdata->obj_name), "tdta%p", tdata);
+ pj_memcpy(pool->obj_name, tdata->obj_name, sizeof(pool->obj_name));
status = pj_atomic_create(tdata->pool, 0, &tdata->ref_cnt);
if (status != PJ_SUCCESS) {
--
2.7.4

View File

@ -1,62 +0,0 @@
From daeb0956524606b597704a90b54d81340e10b3e4 Mon Sep 17 00:00:00 2001
From: Joshua Colp <jcolp@digium.com>
Date: Tue, 7 Mar 2017 12:32:49 +0000
Subject: [PATCH] Add support for registering IPv6 transport type.
This change allows an IPv6 transport type to be registered
and used. The IPv4 transport is found (if available) and the
IPv4 flag added to its type to match how the finding of
IPv6 transport types works.
---
pjsip/src/pjsip/sip_transport.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index 7df6138..ce72814 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -236,6 +236,7 @@ PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag,
int *p_tp_type)
{
unsigned i;
+ pjsip_transport_type_e parent = 0;
PJ_ASSERT_RETURN(tp_flag && tp_name && def_port, PJ_EINVAL);
PJ_ASSERT_RETURN(pj_ansi_strlen(tp_name) <
@@ -243,6 +244,11 @@ PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag,
PJ_ENAMETOOLONG);
for (i=1; i<PJ_ARRAY_SIZE(transport_names); ++i) {
+ if (tp_flag & PJSIP_TRANSPORT_IPV6 &&
+ pj_stricmp2(&transport_names[i].name, tp_name) == 0)
+ {
+ parent = transport_names[i].type;
+ }
if (transport_names[i].type == 0)
break;
}
@@ -250,14 +256,19 @@ PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag,
if (i == PJ_ARRAY_SIZE(transport_names))
return PJ_ETOOMANY;
- transport_names[i].type = (pjsip_transport_type_e)i;
+ if (tp_flag & PJSIP_TRANSPORT_IPV6 && parent) {
+ transport_names[i].type = parent | PJSIP_TRANSPORT_IPV6;
+ } else {
+ transport_names[i].type = (pjsip_transport_type_e)i;
+ }
+
transport_names[i].port = (pj_uint16_t)def_port;
pj_ansi_strcpy(transport_names[i].name_buf, tp_name);
transport_names[i].name = pj_str(transport_names[i].name_buf);
transport_names[i].flag = tp_flag;
if (p_tp_type)
- *p_tp_type = i;
+ *p_tp_type = transport_names[i].type;
return PJ_SUCCESS;
}
--
2.7.4

View File

@ -1,24 +0,0 @@
From 1bc5ca699f523bd8e910203a3eb4dee58f366976 Mon Sep 17 00:00:00 2001
From: Joshua Elson <joshelson@gmail.com>
Date: Mon, 20 Mar 2017 19:28:47 -0600
Subject: [PATCH] Prevent memory corruption on xml tag write
---
pjlib-util/src/pjlib-util/xml.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/pjlib-util/src/pjlib-util/xml.c b/pjlib-util/src/pjlib-util/xml.c
index 296b232..b0aad26 100644
--- a/pjlib-util/src/pjlib-util/xml.c
+++ b/pjlib-util/src/pjlib-util/xml.c
@@ -248,6 +248,7 @@ static int xml_print_node( const pj_xml_node *node, int indent,
if (node->content.slen==0 &&
node->node_head.next==(pj_xml_node*)&node->node_head)
{
+ if (SIZE_LEFT() < 3) return -1;
*p++ = ' ';
*p++ = '/';
*p++ = '>';
--
2.10.1 (Apple Git-78)

View File

@ -1,32 +0,0 @@
Index: trunk/pjsip/src/pjsip/sip_transaction.c
===================================================================
--- a/pjsip/src/pjsip/sip_transaction.c (revision 5244)
+++ b/pjsip/src/pjsip/sip_transaction.c (revision 5572)
@@ -1231,5 +1231,27 @@
PJSIP_EVENT_INIT_TSX_STATE(e, tsx, event_src_type, event_src,
prev_state);
+
+ /* For timer event, release lock to avoid deadlock.
+ * This should be safe because:
+ * 1. The tsx state just switches to TERMINATED or DESTROYED.
+ * 2. There should be no other processing taking place. All other
+ * events, such as the ones handled by tsx_on_state_terminated()
+ * should be ignored.
+ * 3. tsx_shutdown() hasn't been called.
+ * Refer to ticket #2001 (https://trac.pjsip.org/repos/ticket/2001).
+ */
+ if (event_src_type == PJSIP_EVENT_TIMER &&
+ (pj_timer_entry *)event_src == &tsx->timeout_timer)
+ {
+ pj_grp_lock_release(tsx->grp_lock);
+ }
+
(*tsx->tsx_user->on_tsx_state)(tsx, &e);
+
+ if (event_src_type == PJSIP_EVENT_TIMER &&
+ (pj_timer_entry *)event_src == &tsx->timeout_timer)
+ {
+ pj_grp_lock_acquire(tsx->grp_lock);
+ }
}

View File

@ -1,119 +0,0 @@
Index: trunk/pjsip/include/pjsip/sip_transaction.h
===================================================================
--- a/pjsip/include/pjsip/sip_transaction.h (revision 5572)
+++ b/pjsip/include/pjsip/sip_transaction.h (revision 5573)
@@ -180,4 +180,8 @@
* is created by calling #pjsip_tsx_create_key() from an incoming message.
*
+ * IMPORTANT: To prevent deadlock, application should use
+ * #pjsip_tsx_layer_find_tsx2() instead which only adds a reference to
+ * the transaction instead of locking it.
+ *
* @param key The key string to find the transaction.
* @param lock If non-zero, transaction will be locked before the
@@ -190,4 +194,19 @@
PJ_DECL(pjsip_transaction*) pjsip_tsx_layer_find_tsx( const pj_str_t *key,
pj_bool_t lock );
+
+/**
+ * Find a transaction with the specified key. The transaction key normally
+ * is created by calling #pjsip_tsx_create_key() from an incoming message.
+ *
+ * @param key The key string to find the transaction.
+ * @param add_ref If non-zero, transaction's reference will be added
+ * by one before the function returns, to make sure that
+ * it's not deleted by other threads.
+ *
+ * @return The matching transaction instance, or NULL if transaction
+ * can not be found.
+ */
+PJ_DECL(pjsip_transaction*) pjsip_tsx_layer_find_tsx2( const pj_str_t *key,
+ pj_bool_t add_ref );
/**
Index: trunk/pjsip/src/pjsip/sip_transaction.c
===================================================================
--- a/pjsip/src/pjsip/sip_transaction.c (revision 5572)
+++ b/pjsip/src/pjsip/sip_transaction.c (revision 5573)
@@ -642,6 +642,6 @@
* Find a transaction.
*/
-PJ_DEF(pjsip_transaction*) pjsip_tsx_layer_find_tsx( const pj_str_t *key,
- pj_bool_t lock )
+static pjsip_transaction* find_tsx( const pj_str_t *key, pj_bool_t lock,
+ pj_bool_t add_ref )
{
pjsip_transaction *tsx;
@@ -655,5 +655,5 @@
/* Prevent the transaction to get deleted before we have chance to lock it.
*/
- if (tsx && lock)
+ if (tsx)
pj_grp_lock_add_ref(tsx->grp_lock);
@@ -667,10 +667,27 @@
PJ_RACE_ME(5);
- if (tsx && lock) {
- pj_grp_lock_acquire(tsx->grp_lock);
- pj_grp_lock_dec_ref(tsx->grp_lock);
+ if (tsx) {
+ if (lock)
+ pj_grp_lock_acquire(tsx->grp_lock);
+
+ if (!add_ref)
+ pj_grp_lock_dec_ref(tsx->grp_lock);
}
return tsx;
+}
+
+
+PJ_DEF(pjsip_transaction*) pjsip_tsx_layer_find_tsx( const pj_str_t *key,
+ pj_bool_t lock )
+{
+ return find_tsx(key, lock, PJ_FALSE);
+}
+
+
+PJ_DEF(pjsip_transaction*) pjsip_tsx_layer_find_tsx2( const pj_str_t *key,
+ pj_bool_t add_ref )
+{
+ return find_tsx(key, PJ_FALSE, add_ref);
}
Index: trunk/pjsip/src/pjsip/sip_ua_layer.c
===================================================================
--- a/pjsip/src/pjsip/sip_ua_layer.c (revision 5572)
+++ b/pjsip/src/pjsip/sip_ua_layer.c (revision 5573)
@@ -552,10 +552,10 @@
/* Lookup the INVITE transaction */
- tsx = pjsip_tsx_layer_find_tsx(&key, PJ_TRUE);
+ tsx = pjsip_tsx_layer_find_tsx2(&key, PJ_TRUE);
/* We should find the dialog attached to the INVITE transaction */
if (tsx) {
dlg = (pjsip_dialog*) tsx->mod_data[mod_ua.mod.id];
- pj_grp_lock_release(tsx->grp_lock);
+ pj_grp_lock_dec_ref(tsx->grp_lock);
/* Dlg may be NULL on some extreme condition
Index: trunk/pjsip/src/pjsip-ua/sip_inv.c
===================================================================
--- a/pjsip/src/pjsip-ua/sip_inv.c (revision 5572)
+++ b/pjsip/src/pjsip-ua/sip_inv.c (revision 5573)
@@ -3276,5 +3276,5 @@
pjsip_tsx_create_key(rdata->tp_info.pool, &key, PJSIP_ROLE_UAS,
pjsip_get_invite_method(), rdata);
- invite_tsx = pjsip_tsx_layer_find_tsx(&key, PJ_TRUE);
+ invite_tsx = pjsip_tsx_layer_find_tsx2(&key, PJ_TRUE);
if (invite_tsx == NULL) {
@@ -3325,5 +3325,5 @@
if (invite_tsx)
- pj_grp_lock_release(invite_tsx->grp_lock);
+ pj_grp_lock_dec_ref(invite_tsx->grp_lock);
}

View File

@ -1,72 +0,0 @@
Index: pjproject/trunk/pjsip/src/pjsip-ua/sip_timer.c
===================================================================
--- a/pjsip/src/pjsip-ua/sip_timer.c (revision 5557)
+++ b/pjsip/src/pjsip-ua/sip_timer.c (revision 5576)
@@ -333,6 +333,8 @@
pjsip_tx_data *tdata = NULL;
pj_status_t status;
pj_bool_t as_refresher;
+ int entry_id;
+ char obj_name[PJ_MAX_OBJ_NAME];
pj_assert(inv);
@@ -344,7 +346,10 @@
/* Check our role */
as_refresher =
(inv->timer->refresher == TR_UAC && inv->timer->role == PJSIP_ROLE_UAC) ||
- (inv->timer->refresher == TR_UAS && inv->timer->role == PJSIP_ROLE_UAS);
+ (inv->timer->refresher == TR_UAS && inv->timer->role == PJSIP_ROLE_UAS);
+
+ entry_id = entry->id;
+ pj_ansi_strncpy(obj_name, inv->pool->obj_name, PJ_MAX_OBJ_NAME);
/* Do action based on role(refresher or refreshee).
* As refresher:
@@ -353,7 +358,7 @@
* As refreshee:
* - end session if there is no refresh request received.
*/
- if (as_refresher && (entry->id != REFRESHER_EXPIRE_TIMER_ID)) {
+ if (as_refresher && (entry_id != REFRESHER_EXPIRE_TIMER_ID)) {
pj_time_val now;
/* As refresher, reshedule the refresh request on the following:
@@ -414,7 +419,7 @@
}
pj_gettimeofday(&now);
- PJ_LOG(4, (inv->pool->obj_name,
+ PJ_LOG(4, (obj_name,
"Refreshing session after %ds (expiration period=%ds)",
(now.sec-inv->timer->last_refresh.sec),
inv->timer->setting.sess_expires));
@@ -432,7 +437,7 @@
NULL, &tdata);
pj_gettimeofday(&now);
- PJ_LOG(3, (inv->pool->obj_name,
+ PJ_LOG(3, (obj_name,
"No session %s received after %ds "
"(expiration period=%ds), stopping session now!",
(as_refresher?"refresh response":"refresh"),
@@ -451,11 +456,16 @@
status = pjsip_inv_send_msg(inv, tdata);
}
+ /*
+ * At this point, dialog might have already been destroyed,
+ * including its pool used by the invite session.
+ */
+
/* Print error message, if any */
if (status != PJ_SUCCESS) {
- PJ_PERROR(2, (inv->pool->obj_name, status,
+ PJ_PERROR(2, (obj_name, status,
"Error in %s session timer",
- ((as_refresher && entry->id != REFRESHER_EXPIRE_TIMER_ID)?
+ ((as_refresher && entry_id != REFRESHER_EXPIRE_TIMER_ID)?
"refreshing" : "terminating")));
}
}

View File

@ -1,32 +0,0 @@
Index: /pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
===================================================================
--- a/pjlib/src/pj/ssl_sock_ossl.c (revision 5564)
+++ b/pjlib/src/pj/ssl_sock_ossl.c (revision 5565)
@@ -145,5 +145,6 @@
SSL_STATE_NULL,
SSL_STATE_HANDSHAKING,
- SSL_STATE_ESTABLISHED
+ SSL_STATE_ESTABLISHED,
+ SSL_STATE_ERROR
};
@@ -1907,4 +1908,8 @@
buf->len += size_;
+ if (status != PJ_SUCCESS) {
+ ssock->ssl_state = SSL_STATE_ERROR;
+ }
+
ret = (*ssock->param.cb.on_data_read)(ssock, buf->data,
buf->len, status,
@@ -2658,5 +2663,9 @@
/* Current cipher */
cipher = SSL_get_current_cipher(ssock->ossl_ssl);
- info->cipher = (SSL_CIPHER_get_id(cipher) & 0x00FFFFFF);
+ if (cipher) {
+ info->cipher = (SSL_CIPHER_get_id(cipher) & 0x00FFFFFF);
+ } else {
+ info->cipher = PJ_TLS_UNKNOWN_CIPHER;
+ }
/* Remote address */

View File

@ -1,41 +0,0 @@
From f0c717463d569f87a16f9b014033c8ca8939a7b4 Mon Sep 17 00:00:00 2001
From: Mark Michelson <mmichelson@digium.com>
Date: Thu, 13 Apr 2017 16:59:40 -0500
Subject: [PATCH] Parse zero-length multipart body parts correctly.
The calculation of end_body could result in a negative length being
passed to multipart_body_parse_part().
---
pjsip/src/pjsip/sip_multipart.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/pjsip/src/pjsip/sip_multipart.c b/pjsip/src/pjsip/sip_multipart.c
index 8351f7e..b302139 100644
--- a/pjsip/src/pjsip/sip_multipart.c
+++ b/pjsip/src/pjsip/sip_multipart.c
@@ -653,13 +653,15 @@ PJ_DEF(pjsip_msg_body*) pjsip_multipart_parse(pj_pool_t *pool,
end_body = curptr;
- /* The newline preceeding the delimiter is conceptually part of
- * the delimiter, so trim it from the body.
- */
- if (*(end_body-1) == '\n')
- --end_body;
- if (*(end_body-1) == '\r')
- --end_body;
+ if (end_body > start_body) {
+ /* The newline preceeding the delimiter is conceptually part of
+ * the delimiter, so trim it from the body.
+ */
+ if (*(end_body-1) == '\n')
+ --end_body;
+ if (*(end_body-1) == '\r')
+ --end_body;
+ }
/* Now that we have determined the part's boundary, parse it
* to get the header and body part of the part.
--
1.9.1

View File

@ -1,29 +0,0 @@
From b5f0f8868363c482a2c4ce343e3ee6ad256b0708 Mon Sep 17 00:00:00 2001
From: Mark Michelson <mmichelson@digium.com>
Date: Thu, 13 Apr 2017 16:20:07 -0500
Subject: [PATCH] Ensure 2543 transaction key buffer is large enough.
The CSeq method length needs to be factored into the allocated buffer
length. Otherwise, the buffer may not be large enough to accommodate the
entire key.
---
pjsip/src/pjsip/sip_transaction.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c
index c1750dc..2200d8d 100644
--- a/pjsip/src/pjsip/sip_transaction.c
+++ b/pjsip/src/pjsip/sip_transaction.c
@@ -288,7 +288,8 @@ static pj_status_t create_tsx_key_2543( pj_pool_t *pool,
host = &rdata->msg_info.via->sent_by.host;
/* Calculate length required. */
- len_required = 9 + /* CSeq number */
+ len_required = method->name.slen + /* Method */
+ 9 + /* CSeq number */
rdata->msg_info.from->tag.slen + /* From tag. */
rdata->msg_info.cid->id.slen + /* Call-ID */
host->slen + /* Via host. */
--
1.9.1

View File

@ -1,29 +0,0 @@
From 1193681959816effa121c4470748d5faa3a59272 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Thu, 29 Jun 2017 13:42:10 -0600
Subject: [PATCH] Set PJSIP_INV_SUPPORT_UPDATE correctly in
pjsip_inv_verify_request3
pjsip_inv_verify_request3 was setting rem_options when UPDATE was
detected in the Allow header. That's just an internal variable and
doesn't go anywhere. It's '*options' that needs to be set.
---
pjsip/src/pjsip-ua/sip_inv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c
index fbc8ebe..6db7e6b 100644
--- a/pjsip/src/pjsip-ua/sip_inv.c
+++ b/pjsip/src/pjsip-ua/sip_inv.c
@@ -1237,7 +1237,7 @@ PJ_DEF(pj_status_t) pjsip_inv_verify_request3(pjsip_rx_data *rdata,
if (i != allow->count) {
/* UPDATE is present in Allow */
- rem_option |= PJSIP_INV_SUPPORT_UPDATE;
+ *options |= PJSIP_INV_SUPPORT_UPDATE;
}
}
--
2.9.4

View File

@ -1,247 +0,0 @@
From 96c06899d95eaf01d05561554b21e8c63baa7129 Mon Sep 17 00:00:00 2001
From: ming <ming@localhost>
Date: Thu, 27 Jul 2017 06:07:54 +0000
Subject: [PATCH 75/76] Fixed #2030: Improve error handling in OpenSSL socket
---
pjlib/src/pj/ssl_sock_ossl.c | 173 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 156 insertions(+), 17 deletions(-)
diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c
index c466b3c..b8175e1 100644
--- a/pjlib/src/pj/ssl_sock_ossl.c
+++ b/pjlib/src/pj/ssl_sock_ossl.c
@@ -298,14 +298,104 @@ static pj_status_t flush_delayed_send(pj_ssl_sock_t *ssock);
/* Expected maximum value of reason component in OpenSSL error code */
#define MAX_OSSL_ERR_REASON 1200
-static pj_status_t STATUS_FROM_SSL_ERR(pj_ssl_sock_t *ssock,
- unsigned long err)
+
+static char *SSLErrorString (int err)
{
- pj_status_t status;
+ switch (err) {
+ case SSL_ERROR_NONE:
+ return "SSL_ERROR_NONE";
+ case SSL_ERROR_ZERO_RETURN:
+ return "SSL_ERROR_ZERO_RETURN";
+ case SSL_ERROR_WANT_READ:
+ return "SSL_ERROR_WANT_READ";
+ case SSL_ERROR_WANT_WRITE:
+ return "SSL_ERROR_WANT_WRITE";
+ case SSL_ERROR_WANT_CONNECT:
+ return "SSL_ERROR_WANT_CONNECT";
+ case SSL_ERROR_WANT_ACCEPT:
+ return "SSL_ERROR_WANT_ACCEPT";
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ return "SSL_ERROR_WANT_X509_LOOKUP";
+ case SSL_ERROR_SYSCALL:
+ return "SSL_ERROR_SYSCALL";
+ case SSL_ERROR_SSL:
+ return "SSL_ERROR_SSL";
+ default:
+ return "SSL_ERROR_UNKNOWN";
+ }
+}
- /* General SSL error, dig more from OpenSSL error queue */
- if (err == SSL_ERROR_SSL)
- err = ERR_get_error();
+#define ERROR_LOG(msg, err) \
+ PJ_LOG(2,("SSL", "%s (%s): Level: %d err: <%lu> <%s-%s-%s> len: %d", \
+ msg, action, level, err, \
+ (ERR_lib_error_string(err)? ERR_lib_error_string(err): "???"), \
+ (ERR_func_error_string(err)? ERR_func_error_string(err):"???"),\
+ (ERR_reason_error_string(err)? \
+ ERR_reason_error_string(err): "???"), len));
+
+static void SSLLogErrors(char * action, int ret, int ssl_err, int len)
+{
+ char *ssl_err_str = SSLErrorString(ssl_err);
+
+ if (!action) {
+ action = "UNKNOWN";
+ }
+
+ switch (ssl_err) {
+ case SSL_ERROR_SYSCALL:
+ {
+ unsigned long err2 = ERR_get_error();
+ if (err2) {
+ int level = 0;
+ while (err2) {
+ ERROR_LOG("SSL_ERROR_SYSCALL", err2);
+ level++;
+ err2 = ERR_get_error();
+ }
+ } else if (ret == 0) {
+ /* An EOF was observed that violates the protocol */
+
+ /* The TLS/SSL handshake was not successful but was shut down
+ * controlled and by the specifications of the TLS/SSL protocol.
+ */
+ } else if (ret == -1) {
+ /* BIO error - look for more info in errno... */
+ char errStr[250] = "";
+ strerror_r(errno, errStr, sizeof(errStr));
+ /* for now - continue logging these if they occur.... */
+ PJ_LOG(4,("SSL", "BIO error, SSL_ERROR_SYSCALL (%s): "
+ "errno: <%d> <%s> len: %d",
+ action, errno, errStr, len));
+ } else {
+ /* ret!=0 & ret!=-1 & nothing on error stack - is this valid??? */
+ PJ_LOG(2,("SSL", "SSL_ERROR_SYSCALL (%s) ret: %d len: %d",
+ action, ret, len));
+ }
+ break;
+ }
+ case SSL_ERROR_SSL:
+ {
+ unsigned long err2 = ERR_get_error();
+ int level = 0;
+
+ while (err2) {
+ ERROR_LOG("SSL_ERROR_SSL", err2);
+ level++;
+ err2 = ERR_get_error();
+ }
+ break;
+ }
+ default:
+ PJ_LOG(2,("SSL", "%lu [%s] (%s) ret: %d len: %d",
+ ssl_err, ssl_err_str, action, ret, len));
+ break;
+ }
+}
+
+
+static pj_status_t GET_STATUS_FROM_SSL_ERR(unsigned long err)
+{
+ pj_status_t status;
/* OpenSSL error range is much wider than PJLIB errno space, so
* if it exceeds the space, only the error reason will be kept.
@@ -317,13 +407,49 @@ static pj_status_t STATUS_FROM_SSL_ERR(pj_ssl_sock_t *ssock,
status = ERR_GET_REASON(err);
status += PJ_SSL_ERRNO_START;
- ssock->last_err = err;
return status;
}
+/* err contains ERR_get_error() status */
+static pj_status_t STATUS_FROM_SSL_ERR(char *action, pj_ssl_sock_t *ssock,
+ unsigned long err)
+{
+ int level = 0;
+ int len = 0; //dummy
+
+ ERROR_LOG("STATUS_FROM_SSL_ERR", err);
+ level++;
+
+ /* General SSL error, dig more from OpenSSL error queue */
+ if (err == SSL_ERROR_SSL) {
+ err = ERR_get_error();
+ ERROR_LOG("STATUS_FROM_SSL_ERR", err);
+ }
+
+ ssock->last_err = err;
+ return GET_STATUS_FROM_SSL_ERR(err);
+}
+
+/* err contains SSL_get_error() status */
+static pj_status_t STATUS_FROM_SSL_ERR2(char *action, pj_ssl_sock_t *ssock,
+ int ret, int err, int len)
+{
+ unsigned long ssl_err = err;
+
+ if (err == SSL_ERROR_SSL) {
+ ssl_err = ERR_peek_error();
+ }
+
+ /* Dig for more from OpenSSL error queue */
+ SSLLogErrors(action, ret, err, len);
+
+ ssock->last_err = ssl_err;
+ return GET_STATUS_FROM_SSL_ERR(ssl_err);
+}
+
static pj_status_t GET_SSL_STATUS(pj_ssl_sock_t *ssock)
{
- return STATUS_FROM_SSL_ERR(ssock, ERR_get_error());
+ return STATUS_FROM_SSL_ERR("status", ssock, ERR_get_error());
}
@@ -1514,7 +1640,7 @@ static pj_bool_t on_handshake_complete(pj_ssl_sock_t *ssock,
unsigned long err;
err = ERR_get_error();
if (err != SSL_ERROR_NONE)
- status = STATUS_FROM_SSL_ERR(ssock, err);
+ status = STATUS_FROM_SSL_ERR("connecting", ssock, err);
}
reset_ssl_sock_state(ssock);
}
@@ -1833,11 +1959,11 @@ static pj_status_t do_handshake(pj_ssl_sock_t *ssock)
}
if (err < 0) {
- err = SSL_get_error(ssock->ossl_ssl, err);
- if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ)
+ int err2 = SSL_get_error(ssock->ossl_ssl, err);
+ if (err2 != SSL_ERROR_NONE && err2 != SSL_ERROR_WANT_READ)
{
/* Handshake fails */
- status = STATUS_FROM_SSL_ERR(ssock, err);
+ status = STATUS_FROM_SSL_ERR2("Handshake", ssock, err, err2, 0);
return status;
}
}
@@ -1913,6 +2039,7 @@ static pj_bool_t asock_on_data_read (pj_activesock_t *asock,
read_data_t *buf = *(OFFSET_OF_READ_DATA_PTR(ssock, data));
void *data_ = (pj_int8_t*)buf->data + buf->len;
int size_ = (int)(ssock->read_size - buf->len);
+ int len = size_;
/* SSL_read() may write some data to BIO write when re-negotiation
* is on progress, so let's protect it with write mutex.
@@ -1965,10 +2092,22 @@ static pj_bool_t asock_on_data_read (pj_activesock_t *asock,
*/
if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ)
{
- /* Reset SSL socket state, then return PJ_FALSE */
- status = STATUS_FROM_SSL_ERR(ssock, err);
- reset_ssl_sock_state(ssock);
- goto on_error;
+ if (err == SSL_ERROR_SYSCALL && size_ == -1 &&
+ ERR_peek_error() == 0 && errno == 0)
+ {
+ status = STATUS_FROM_SSL_ERR2("Read", ssock, size_,
+ err, len);
+ PJ_LOG(4,("SSL", "SSL_read() = -1, with "
+ "SSL_ERROR_SYSCALL, no SSL error, "
+ "and errno = 0 - skip BIO error"));
+ /* Ignore these errors */
+ } else {
+ /* Reset SSL socket state, then return PJ_FALSE */
+ status = STATUS_FROM_SSL_ERR2("Read", ssock, size_,
+ err, len);
+ reset_ssl_sock_state(ssock);
+ goto on_error;
+ }
}
status = do_handshake(ssock);
@@ -2856,7 +2995,7 @@ static pj_status_t ssl_write(pj_ssl_sock_t *ssock,
status = PJ_EBUSY;
} else {
/* Some problem occured */
- status = STATUS_FROM_SSL_ERR(ssock, err);
+ status = STATUS_FROM_SSL_ERR2("Write", ssock, nwritten, err, size);
}
} else {
/* nwritten < *size, shouldn't happen, unless write BIO cannot hold
--
2.9.4

View File

@ -1,2 +1,2 @@
PJPROJECT_VERSION = 2.6
PJPROJECT_VERSION = 2.7