[Asterisk-code-review] pjsip: Upgrade bundled version to pjproject 2.11.1 (asterisk[16])

Michael Bradeen asteriskteam at digium.com
Wed Dec 22 12:50:07 CST 2021


Michael Bradeen has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/17710 )


Change subject: pjsip: Upgrade bundled version to pjproject 2.11.1
......................................................................

pjsip: Upgrade bundled version to pjproject 2.11.1

res/res_pjsip_pidf_body_generator: update pidf body generator to add
note to both the presence (previous behavior) as well as the nested
tuple so notified uas can find it in either place.

third-party/versions.mak: increment pjproject version to 2.11.1

third-party/pjproject: Removes the following patches as they have
been resolved in version 2.11.1
0000-solaris.patch
0011-sip_inv_patch.patch
0020-pjlib_cancel_timer_0.patch
0050-fix-race-parallel-build.patch
0060-clone-sdp-for-sip-timer-refresh-invite.patch
0070-fix-incorrect-copying-when-creating-cancel.patch
0080-fix-sdp-neg-modify-local-offer.patch
0110-tls-parent-listener-destroyed.patch
0111-ssl-premature-destroy.patch

ASTERISK-29351

Change-Id: If610e36b66d6137a1bf40e2a47de27c94252efd8
---
M res/res_pjsip_pidf_body_generator.c
D third-party/pjproject/patches/0000-solaris.patch
D third-party/pjproject/patches/0011-sip_inv_patch.patch
D third-party/pjproject/patches/0020-pjlib_cancel_timer_0.patch
D third-party/pjproject/patches/0050-fix-race-parallel-build.patch
D third-party/pjproject/patches/0060-clone-sdp-for-sip-timer-refresh-invite.patch
D third-party/pjproject/patches/0070-fix-incorrect-copying-when-creating-cancel.patch
D third-party/pjproject/patches/0080-fix-sdp-neg-modify-local-offer.patch
D third-party/pjproject/patches/0110-tls-parent-listener-destroyed.patch
D third-party/pjproject/patches/0111-ssl-premature-destroy.patch
A third-party/pjproject/pjproject-2.11.1.tar.bz2.md5
M third-party/versions.mak
12 files changed, 15 insertions(+), 686 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/10/17710/1

diff --git a/res/res_pjsip_pidf_body_generator.c b/res/res_pjsip_pidf_body_generator.c
index 8bc062e..f7335f0 100644
--- a/res/res_pjsip_pidf_body_generator.c
+++ b/res/res_pjsip_pidf_body_generator.c
@@ -60,6 +60,10 @@
 	ast_sip_presence_exten_state_to_str(state_data->exten_state, &statestring,
 			&pidfstate, &pidfnote, &local_state, 0);
 
+	/* Setting the note both here inside the presence and then again inside the nested
+	 * tuple to cover the two places that a user agent may look for it (pjsip based
+	 * in particular)
+	 */
 	if (!pjpidf_pres_add_note(state_data->pool, pres, pj_cstr(&note, pidfnote))) {
 		ast_log(LOG_WARNING, "Unable to add note to PIDF presence\n");
 		return -1;
@@ -71,6 +75,13 @@
 		return -1;
 	}
 
+	/* Second note insertion, this time within the tuple
+	 */
+	if (!pjpidf_pres_add_note(state_data->pool, tuple, pj_cstr(&note, pidfnote))) {
+		ast_log(LOG_WARNING, "Unable to add note to PIDF tuple\n");
+		return -1;
+	}
+
 	ast_sip_sanitize_xml(state_data->remote, sanitized, sizeof(sanitized));
 	pjpidf_tuple_set_contact(state_data->pool, tuple, pj_cstr(&contact, sanitized));
 	pjpidf_tuple_set_contact_prio(state_data->pool, tuple, pj_cstr(&priority, "1"));
diff --git a/third-party/pjproject/patches/0000-solaris.patch b/third-party/pjproject/patches/0000-solaris.patch
deleted file mode 100644
index 155cdbe..0000000
--- a/third-party/pjproject/patches/0000-solaris.patch
+++ /dev/null
@@ -1,135 +0,0 @@
-From 1ac599a0f29500a15faf0dbbdc2565cc7dce2420 Mon Sep 17 00:00:00 2001
-From: Shaun Ruffell <sruffell at digium.com>
-Date: Fri, 7 Sep 2012 14:31:19 -0500
-Subject: [PATCH 4/5] pjproject: Fix for Solaris builds. Do not undef s_addr.
-
-pjproject, in order to solve build problems on Windows [1], undefines s_addr in
-one of it's headers that is included in res_rtp_asterisk.c. On Solaris s_addr is
-not a structure member, but defined to map to the real strucuture member,
-therefore when building on Solaris it's possible to get build errors like:
-
-    [CC] res_rtp_asterisk.c -> res_rtp_asterisk.o
-    In file included from /export/home/admin/asterisk-11-svn/include/asterisk/stun.h:29,
-                     from res_rtp_asterisk.c:51:
-    /export/home/admin/asterisk-11-svn/include/asterisk/network.h: In function `inaddrcmp':
-    /export/home/admin/asterisk-11-svn/include/asterisk/network.h:92: error: structure has no member named `s_addr'
-    /export/home/admin/asterisk-11-svn/include/asterisk/network.h:92: error: structure has no member named `s_addr'
-    res_rtp_asterisk.c: In function `ast_rtp_on_ice_tx_pkt':
-    res_rtp_asterisk.c:706: warning: dereferencing type-punned pointer will break strict-aliasing rules
-    res_rtp_asterisk.c:710: warning: dereferencing type-punned pointer will break strict-aliasing rules
-    res_rtp_asterisk.c: In function `rtp_add_candidates_to_ice':
-    res_rtp_asterisk.c:1085: error: structure has no member named `s_addr'
-    make[2]: *** [res_rtp_asterisk.o] Error 1
-    make[1]: *** [res] Error 2
-    make[1]: Leaving directory `/export/home/admin/asterisk-11-svn'
-    gmake: *** [_cleantest_all] Error 2
-
-Unfortunately, in order to make this work, I also had to make sure pjproject
-only used the typdef pj_in_addr and not the struct pj_in_addr so that when
-building Asterisk I could "typedef struct in_addr pj_in_addr". It's possible
-then that the library and users of those interfaces in Asterisk have a different
-idea about the type of the argument. While on the surface it looks like they are
-all 32 bit big endian values.
-
-[1] http://trac.pjsip.org/repos/changeset/484
-
-Reported-by: Ben Klang
-(issues ASTERISK-20366)
-
-Updated by ASTERISK-27997
----
- pjlib/include/pj/sock.h         | 8 +++++++-
- pjlib/src/pj/sock_bsd.c         | 2 +-
- pjlib/src/pj/sock_symbian.cpp   | 2 +-
- pjlib/src/pj/sock_uwp.cpp       | 2 +-
- pjsip/src/test/transport_test.c | 2 +-
- 5 files changed, 11 insertions(+), 5 deletions(-)
-
-diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h
-index 4daf298..c35833c 100644
---- a/pjlib/include/pj/sock.h
-+++ b/pjlib/include/pj/sock.h
-@@ -484,6 +484,7 @@ typedef enum pj_socket_sd_type
-  */
- #define PJ_INVALID_SOCKET   (-1)
- 
-+#ifndef _ASTERISK_H
- /* Must undefine s_addr because of pj_in_addr below */
- #undef s_addr
- 
-@@ -495,6 +496,11 @@ typedef struct pj_in_addr
-     pj_uint32_t	s_addr;		/**< The 32bit IP address.	    */
- } pj_in_addr;
- 
-+#else
-+#include <sys/types.h>
-+#include <netinet/in.h>
-+typedef struct in_addr pj_in_addr;
-+#endif
- 
- /**
-  * Maximum length of text representation of an IPv4 address.
-@@ -712,7 +718,7 @@ PJ_DECL(char*) pj_inet_ntoa(pj_in_addr inaddr);
-  *
-  * @return	nonzero if the address is valid, zero if not.
-  */
--PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp);
-+PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp);
- 
- /**
-  * This function converts an address in its standard text presentation form
-diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c
-index e416991..940fce1 100644
---- a/pjlib/src/pj/sock_bsd.c
-+++ b/pjlib/src/pj/sock_bsd.c
-@@ -244,7 +244,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
-  * numbers-and-dots notation into binary data and stores it in the structure
-  * that inp points to. 
-  */
--PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
-+PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
- {
-     char tempaddr[PJ_INET_ADDRSTRLEN];
- 
-diff --git a/pjlib/src/pj/sock_symbian.cpp b/pjlib/src/pj/sock_symbian.cpp
-index 09239b0..e72bbda 100644
---- a/pjlib/src/pj/sock_symbian.cpp
-+++ b/pjlib/src/pj/sock_symbian.cpp
-@@ -299,7 +299,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
-  * numbers-and-dots notation into binary data and stores it in the structure
-  * that inp points to. 
-  */
--PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
-+PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
- {
-     enum { MAXIPLEN = PJ_INET_ADDRSTRLEN };
- 
-diff --git a/pjlib/src/pj/sock_uwp.cpp b/pjlib/src/pj/sock_uwp.cpp
-index 876c328..40250bf 100644
---- a/pjlib/src/pj/sock_uwp.cpp
-+++ b/pjlib/src/pj/sock_uwp.cpp
-@@ -933,7 +933,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
-  * numbers-and-dots notation into binary data and stores it in the structure
-  * that inp points to. 
-  */
--PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
-+PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
- {
-     char tempaddr[PJ_INET_ADDRSTRLEN];
- 
-diff --git a/pjsip/src/test/transport_test.c b/pjsip/src/test/transport_test.c
-index e5083d1..c429cc7 100644
---- a/pjsip/src/test/transport_test.c
-+++ b/pjsip/src/test/transport_test.c
-@@ -35,7 +35,7 @@ int generic_transport_test(pjsip_transport *tp)
- 
-     /* Check that local address name is valid. */
-     {
--	struct pj_in_addr addr;
-+	pj_in_addr addr;
- 
- 	if (pj_inet_pton(pj_AF_INET(), &tp->local_name.host,
- 			 &addr) == PJ_SUCCESS)
--- 
-2.7.4
-
diff --git a/third-party/pjproject/patches/0011-sip_inv_patch.patch b/third-party/pjproject/patches/0011-sip_inv_patch.patch
deleted file mode 100644
index 7f77c74..0000000
--- a/third-party/pjproject/patches/0011-sip_inv_patch.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-commit c3c1bf45cae2a35003aa16c267d59f97027f9c5e
-Author: Kevin Harwell <kharwell at digium.com>
-Date:   Thu Jun 11 11:11:13 2020 -0500
-
-    sip_inv - fix invite session ref count crash
-    
-    Ensure the session's ref count is only decremented under proper conditons.
-    
-    For more details see the following issue report:
-    https://github.com/pjsip/pjproject/issues/2443
-    
-    Patch supplied by sauwming
-
-diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c
-index ca225015b..7c11b1c8e 100644
---- a/pjsip/src/pjsip-ua/sip_inv.c
-+++ b/pjsip/src/pjsip-ua/sip_inv.c
-@@ -323,9 +323,19 @@ static void inv_set_state(pjsip_inv_session *inv, pjsip_inv_state state,
- 	(*mod_inv.cb.on_state_changed)(inv, e);
-     pjsip_inv_dec_ref(inv);
- 
--    /* Only decrement when previous state is not already DISCONNECTED */
-+    /* The above callback may change the state, so we need to be careful here
-+     * and only decrement inv under the following conditions:
-+     * 1. If the state parameter is DISCONNECTED, and previous state is not
-+     *    already DISCONNECTED.
-+     *    This is to make sure that dec_ref() is not called more than once.
-+     * 2. If current state is PJSIP_INV_STATE_DISCONNECTED.
-+     *    This is to make sure that dec_ref() is not called if user restarts
-+     *    inv within the callback. Note that this check must be last since
-+     *    inv may have already been destroyed.
-+     */
-     if (state == PJSIP_INV_STATE_DISCONNECTED &&
--	prev_state != PJSIP_INV_STATE_DISCONNECTED) 
-+	prev_state != PJSIP_INV_STATE_DISCONNECTED &&
-+	inv->state == PJSIP_INV_STATE_DISCONNECTED) 
-     {
- 	pjsip_inv_dec_ref(inv);
-     }
diff --git a/third-party/pjproject/patches/0020-pjlib_cancel_timer_0.patch b/third-party/pjproject/patches/0020-pjlib_cancel_timer_0.patch
deleted file mode 100644
index 09f72d8..0000000
--- a/third-party/pjproject/patches/0020-pjlib_cancel_timer_0.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-commit 40dd48d10911f4ff9b8dfbf16428fbc9acc434ba
-Author: Riza Sulistyo <trengginas at users.noreply.github.com>
-Date:   Thu Jul 9 17:47:24 2020 +0700
-
-    Modify timer_id check on cancel() (#2463)
-    
-    * modify timer_id check on cancel().
-    
-    * modification based on comments.
-
-diff --git a/pjlib/include/pj/timer.h b/pjlib/include/pj/timer.h
-index b738a6e76..4b76ab65d 100644
---- a/pjlib/include/pj/timer.h
-+++ b/pjlib/include/pj/timer.h
-@@ -120,7 +120,10 @@ typedef struct pj_timer_entry
- 
-     /** 
-      * Internal unique timer ID, which is assigned by the timer heap. 
--     * Application should not touch this ID.
-+     * Positive values indicate that the timer entry is running, 
-+     * while -1 means that it's not. Any other value may indicate that it 
-+     * hasn't been properly initialised or is in a bad state.
-+     * Application should not touch this ID. 
-      */
-     pj_timer_id_t _timer_id;
- 
-diff --git a/pjlib/src/pj/timer.c b/pjlib/src/pj/timer.c
-index 66516fce8..34966c481 100644
---- a/pjlib/src/pj/timer.c
-+++ b/pjlib/src/pj/timer.c
-@@ -535,7 +535,7 @@ static int cancel( pj_timer_heap_t *ht,
-     PJ_CHECK_STACK();
- 
-     // Check to see if the timer_id is out of range
--    if (entry->_timer_id < 0 || (pj_size_t)entry->_timer_id > ht->max_size) {
-+    if (entry->_timer_id < 1 || (pj_size_t)entry->_timer_id >= ht->max_size) {
- 	entry->_timer_id = -1;
-     	return 0;
-     }
diff --git a/third-party/pjproject/patches/0050-fix-race-parallel-build.patch b/third-party/pjproject/patches/0050-fix-race-parallel-build.patch
deleted file mode 100644
index 674baa2..0000000
--- a/third-party/pjproject/patches/0050-fix-race-parallel-build.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From 78683646c8bc670ec730a42494e075f671a08e28 Mon Sep 17 00:00:00 2001
-From: Guido Falsi <mad at madpilot.net>
-Date: Mon, 11 May 2020 08:50:39 +0200
-Subject: [PATCH] Fix race condition in parallel builds (#2426)
-
-* Some targets residing in `OBJDIRS` are missing a dependency on that directory, which results in a race condition, causing build to fail sometimes due to the directory not existing when running parallel builds.
-
-* The `PJSUA_LIB` variable is not defined anywhere, resulting in an empty value, and no correct dependency on the pjsua shared library for `pjsua2`. The correct variable seems to be `PJSUA_LIB_LIB`, defined at the start of this same `Makefile`.
----
- build/rules.mak      | 12 ++++++------
- pjsip/build/Makefile |  2 +-
- 2 files changed, 7 insertions(+), 7 deletions(-)
-
-diff --git a/build/rules.mak b/build/rules.mak
-index 8fa98655e..912199c41 100644
---- a/build/rules.mak
-+++ b/build/rules.mak
-@@ -129,7 +129,7 @@ endif
- $(OBJDIR)/$(app).o: $(OBJDIRS) $(OBJS)
- 	$(CROSS_COMPILE)ld -r -o $@ $(OBJS)
- 
--$(OBJDIR)/$(app).ko: $(OBJDIR)/$(app).o
-+$(OBJDIR)/$(app).ko: $(OBJDIR)/$(app).o | $(OBJDIRS)
- 	@echo Creating kbuild Makefile...
- 	@echo "# Our module name:" > $(OBJDIR)/Makefile
- 	@echo 'obj-m += $(app).o' >> $(OBJDIR)/Makefile
-@@ -154,27 +154,27 @@ $(OBJDIR)/$(app).ko: $(OBJDIR)/$(app).o
- ../lib/$(app).ko: $(LIB) $(OBJDIR)/$(app).ko
- 	cp $(OBJDIR)/$(app).ko ../lib
- 
--$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.m
-+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.m | $(OBJDIRS)
- 	$(CC) $($(APP)_CFLAGS) \
- 		$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
- 		$(subst /,$(HOST_PSEP),$<) 
- 
--$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c
-+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c | $(OBJDIRS)
- 	$(CC) $($(APP)_CFLAGS) \
- 		$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
- 		$(subst /,$(HOST_PSEP),$<) 
- 
--$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.S
-+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.S | $(OBJDIRS)
- 	$(CC) $($(APP)_CFLAGS) \
- 		$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
- 		$(subst /,$(HOST_PSEP),$<) 
- 
--$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cpp
-+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cpp | $(OBJDIRS)
- 	$(CXX) $($(APP)_CXXFLAGS) \
- 		$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
- 		$(subst /,$(HOST_PSEP),$<)
- 
--$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cc
-+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cc | $(OBJDIRS)
- 	$(CXX) $($(APP)_CXXFLAGS) \
- 		$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
- 		$(subst /,$(HOST_PSEP),$<)
-diff --git a/pjsip/build/Makefile b/pjsip/build/Makefile
-index b85c7817a..20777909f 100644
---- a/pjsip/build/Makefile
-+++ b/pjsip/build/Makefile
-@@ -262,7 +262,7 @@ $(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME): $(PJSIP_LIB) $(PJSIP_SONAME) $(PJSIP_SIMPL
- 
- pjsua2-lib: $(PJSUA2_LIB_LIB)
- $(PJSUA2_LIB_SONAME): $(PJSUA2_LIB_LIB)
--$(PJSUA2_LIB_LIB) $(PJSUA2_LIB_SONAME): $(PJSUA_LIB) $(PSJUA_LIB_SONAME) $(PJSIP_LIB) $(PJSIP_SONAME) $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME) $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME)
-+$(PJSUA2_LIB_LIB) $(PJSUA2_LIB_SONAME): $(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME) $(PJSIP_LIB) $(PJSIP_SONAME) $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME) $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME)
- 	$(MAKE) -f $(RULES_MAK) APP=PJSUA2_LIB app=pjsua2-lib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
- 
- pjsip-test: $(TEST_EXE)
diff --git a/third-party/pjproject/patches/0060-clone-sdp-for-sip-timer-refresh-invite.patch b/third-party/pjproject/patches/0060-clone-sdp-for-sip-timer-refresh-invite.patch
deleted file mode 100644
index f1f180a..0000000
--- a/third-party/pjproject/patches/0060-clone-sdp-for-sip-timer-refresh-invite.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff -ur source.orig/pjmedia/src/pjmedia/sdp_neg.c source/pjmedia/src/pjmedia/sdp_neg.c
---- source.orig/pjmedia/src/pjmedia/sdp_neg.c	2020-07-02 10:35:42.022459904 +0200
-+++ source/pjmedia/src/pjmedia/sdp_neg.c	2020-07-02 10:33:24.996316867 +0200
-@@ -906,7 +906,7 @@
-  * after receiving remote answer.
-  */
- static pj_status_t process_answer(pj_pool_t *pool,
--				  pjmedia_sdp_session *offer,
-+				  pjmedia_sdp_session *local_offer,
- 				  pjmedia_sdp_session *answer,
- 				  pj_bool_t allow_asym,
- 				  pjmedia_sdp_session **p_active)
-@@ -914,10 +914,14 @@
-     unsigned omi = 0; /* Offer media index */
-     unsigned ami = 0; /* Answer media index */
-     pj_bool_t has_active = PJ_FALSE;
-+    pjmedia_sdp_session *offer;
-     pj_status_t status;
- 
-     /* Check arguments. */
--    PJ_ASSERT_RETURN(pool && offer && answer && p_active, PJ_EINVAL);
-+    PJ_ASSERT_RETURN(pool && local_offer && answer && p_active, PJ_EINVAL);
-+
-+    /* Duplicate local offer SDP. */
-+    offer = pjmedia_sdp_session_clone(pool, local_offer);
- 
-     /* Check that media count match between offer and answer */
-     // Ticket #527, different media count is allowed for more interoperability,
diff --git a/third-party/pjproject/patches/0070-fix-incorrect-copying-when-creating-cancel.patch b/third-party/pjproject/patches/0070-fix-incorrect-copying-when-creating-cancel.patch
deleted file mode 100644
index 95725c1..0000000
--- a/third-party/pjproject/patches/0070-fix-incorrect-copying-when-creating-cancel.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From ce18018cc17bef8f80c08686e3a7b28384ef3ba5 Mon Sep 17 00:00:00 2001
-From: sauwming <ming at teluu.com>
-Date: Mon, 12 Oct 2020 13:31:25 +0800
-Subject: [PATCH] Fix incorrect copying of destination info when creating
- CANCEL (#2546)
-
----
- pjsip/src/pjsip/sip_util.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/pjsip/src/pjsip/sip_util.c b/pjsip/src/pjsip/sip_util.c
-index d10a6fa30..a1bf878ea 100644
---- a/pjsip/src/pjsip/sip_util.c
-+++ b/pjsip/src/pjsip/sip_util.c
-@@ -779,14 +779,14 @@ PJ_DEF(pj_status_t) pjsip_endpt_create_cancel( pjsip_endpoint *endpt,
- 	    pjsip_hdr_clone(cancel_tdata->pool, req_tdata->saved_strict_route);
-     }
- 
--    /* Copy the destination host name from the original request */
--    pj_strdup(cancel_tdata->pool, &cancel_tdata->dest_info.name,
--	      &req_tdata->dest_info.name);
--
--    /* Finally copy the destination info from the original request */
-+    /* Copy the destination info from the original request */
-     pj_memcpy(&cancel_tdata->dest_info, &req_tdata->dest_info,
- 	      sizeof(req_tdata->dest_info));
- 
-+    /* Finally, copy the destination host name from the original request */
-+    pj_strdup(cancel_tdata->pool, &cancel_tdata->dest_info.name,
-+	      &req_tdata->dest_info.name);
-+
-     /* Done.
-      * Return the transmit buffer containing the CANCEL request.
-      */
--- 
-2.25.1
-
diff --git a/third-party/pjproject/patches/0080-fix-sdp-neg-modify-local-offer.patch b/third-party/pjproject/patches/0080-fix-sdp-neg-modify-local-offer.patch
deleted file mode 100644
index c27a489..0000000
--- a/third-party/pjproject/patches/0080-fix-sdp-neg-modify-local-offer.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-diff --git a/pjmedia/src/pjmedia/sdp_neg.c b/pjmedia/src/pjmedia/sdp_neg.c
-index 3b85b4273..a14009662 100644
---- a/pjmedia/src/pjmedia/sdp_neg.c
-+++ b/pjmedia/src/pjmedia/sdp_neg.c
-@@ -304,7 +304,6 @@ PJ_DEF(pj_status_t) pjmedia_sdp_neg_modify_local_offer2(
- {
-     pjmedia_sdp_session *new_offer;
-     pjmedia_sdp_session *old_offer;
--    char media_used[PJMEDIA_MAX_SDP_MEDIA];
-     unsigned oi; /* old offer media index */
-     pj_status_t status;
- 
-@@ -323,8 +322,19 @@ PJ_DEF(pj_status_t) pjmedia_sdp_neg_modify_local_offer2(
-     /* Change state to STATE_LOCAL_OFFER */
-     neg->state = PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER;
- 
-+    /* When there is no active local SDP in state PJMEDIA_SDP_NEG_STATE_DONE,
-+     * it means that the previous initial SDP nego must have been failed,
-+     * so we'll just set the local SDP offer here.
-+     */
-+    if (!neg->active_local_sdp) {
-+	neg->initial_sdp_tmp = NULL;
-+	neg->initial_sdp = pjmedia_sdp_session_clone(pool, local);
-+	neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, local);
-+
-+	return PJ_SUCCESS;
-+    }
-+
-     /* Init vars */
--    pj_bzero(media_used, sizeof(media_used));
-     old_offer = neg->active_local_sdp;
-     new_offer = pjmedia_sdp_session_clone(pool, local);
- 
diff --git a/third-party/pjproject/patches/0110-tls-parent-listener-destroyed.patch b/third-party/pjproject/patches/0110-tls-parent-listener-destroyed.patch
deleted file mode 100644
index 81781f2..0000000
--- a/third-party/pjproject/patches/0110-tls-parent-listener-destroyed.patch
+++ /dev/null
@@ -1,166 +0,0 @@
-From bb92c97ea512aa0ef316c9b2335c7d57b84dfc9a Mon Sep 17 00:00:00 2001
-From: Nanang Izzuddin <nanang at teluu.com>
-Date: Wed, 16 Jun 2021 12:12:35 +0700
-Subject: [PATCH 1/2] - Avoid SSL socket parent/listener getting destroyed
- during handshake by increasing parent's reference count. - Add missing SSL
- socket close when the newly accepted SSL socket is discarded in SIP TLS
- transport.
-
----
- pjlib/src/pj/ssl_sock_imp_common.c  | 44 +++++++++++++++++++++--------
- pjsip/src/pjsip/sip_transport_tls.c | 23 ++++++++++++++-
- 2 files changed, 55 insertions(+), 12 deletions(-)
-
-diff --git a/pjlib/src/pj/ssl_sock_imp_common.c b/pjlib/src/pj/ssl_sock_imp_common.c
-index bc468bcb3..abec31805 100644
---- a/pjlib/src/pj/ssl_sock_imp_common.c
-+++ b/pjlib/src/pj/ssl_sock_imp_common.c
-@@ -224,6 +224,8 @@ static pj_bool_t on_handshake_complete(pj_ssl_sock_t *ssock,
- 
-     /* Accepting */
-     if (ssock->is_server) {
-+	pj_bool_t ret = PJ_TRUE;
-+
- 	if (status != PJ_SUCCESS) {
- 	    /* Handshake failed in accepting, destroy our self silently. */
- 
-@@ -241,6 +243,12 @@ static pj_bool_t on_handshake_complete(pj_ssl_sock_t *ssock,
- 		      status);
- 	    }
- 
-+	    /* Decrement ref count of parent */
-+	    if (ssock->parent->param.grp_lock) {
-+		pj_grp_lock_dec_ref(ssock->parent->param.grp_lock);
-+		ssock->parent = NULL;
-+	    }
-+
- 	    /* Originally, this is a workaround for ticket #985. However,
- 	     * a race condition may occur in multiple worker threads
- 	     * environment when we are destroying SSL objects while other
-@@ -284,23 +292,29 @@ static pj_bool_t on_handshake_complete(pj_ssl_sock_t *ssock,
- 
- 	    return PJ_FALSE;
- 	}
-+
- 	/* Notify application the newly accepted SSL socket */
- 	if (ssock->param.cb.on_accept_complete2) {
--	    pj_bool_t ret;
- 	    ret = (*ssock->param.cb.on_accept_complete2) 
- 		    (ssock->parent, ssock, (pj_sockaddr_t*)&ssock->rem_addr, 
- 		    pj_sockaddr_get_len((pj_sockaddr_t*)&ssock->rem_addr), 
- 		    status);
--	    if (ret == PJ_FALSE)
--		return PJ_FALSE;	
- 	} else if (ssock->param.cb.on_accept_complete) {
--	    pj_bool_t ret;
- 	    ret = (*ssock->param.cb.on_accept_complete)
- 		      (ssock->parent, ssock, (pj_sockaddr_t*)&ssock->rem_addr,
- 		       pj_sockaddr_get_len((pj_sockaddr_t*)&ssock->rem_addr));
--	    if (ret == PJ_FALSE)
--		return PJ_FALSE;
- 	}
-+
-+	/* Decrement ref count of parent and reset parent (we don't need it
-+	 * anymore, right?).
-+	 */
-+	if (ssock->parent->param.grp_lock) {
-+	    pj_grp_lock_dec_ref(ssock->parent->param.grp_lock);
-+	    ssock->parent = NULL;
-+	}
-+
-+	if (ret == PJ_FALSE)
-+	    return PJ_FALSE;
-     }
- 
-     /* Connecting */
-@@ -864,9 +878,13 @@ static pj_bool_t asock_on_accept_complete (pj_activesock_t *asock,
-     if (status != PJ_SUCCESS)
- 	goto on_return;
- 
-+    /* Set parent and add ref count (avoid parent destroy during handshake) */
-+    ssock->parent = ssock_parent;
-+    if (ssock->parent->param.grp_lock)
-+	pj_grp_lock_add_ref(ssock->parent->param.grp_lock);
-+
-     /* Update new SSL socket attributes */
-     ssock->sock = newsock;
--    ssock->parent = ssock_parent;
-     ssock->is_server = PJ_TRUE;
-     if (ssock_parent->cert) {
- 	status = pj_ssl_sock_set_certificate(ssock, ssock->pool, 
-@@ -913,16 +931,20 @@ static pj_bool_t asock_on_accept_complete (pj_activesock_t *asock,
-     ssock->asock_rbuf = (void**)pj_pool_calloc(ssock->pool, 
- 					       ssock->param.async_cnt,
- 					       sizeof(void*));
--    if (!ssock->asock_rbuf)
--        return PJ_ENOMEM;
-+    if (!ssock->asock_rbuf) {
-+		status = PJ_ENOMEM;
-+		goto on_return;
-+	}
- 
-     for (i = 0; i<ssock->param.async_cnt; ++i) {
--	ssock->asock_rbuf[i] = (void*) pj_pool_alloc(
-+		ssock->asock_rbuf[i] = (void*) pj_pool_alloc(
- 					    ssock->pool, 
- 					    ssock->param.read_buffer_size + 
- 					    sizeof(read_data_t*));
--        if (!ssock->asock_rbuf[i])
--            return PJ_ENOMEM;
-+		if (!ssock->asock_rbuf[i]) {
-+			status = PJ_ENOMEM;
-+			goto on_return;
-+		}
-     }
- 
-     /* Create active socket */
-diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c
-index 17b7ae3de..ce524d53f 100644
---- a/pjsip/src/pjsip/sip_transport_tls.c
-+++ b/pjsip/src/pjsip/sip_transport_tls.c
-@@ -1325,9 +1325,26 @@ static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock,
-     PJ_UNUSED_ARG(src_addr_len);
- 
-     listener = (struct tls_listener*) pj_ssl_sock_get_user_data(ssock);
-+    if (!listener) {
-+	/* Listener already destroyed, e.g: after TCP accept but before SSL
-+	 * handshake is completed.
-+	 */
-+	if (new_ssock && accept_status == PJ_SUCCESS) {
-+	    /* Close the SSL socket if the accept op is successful */
-+	    PJ_LOG(4,(THIS_FILE,
-+		      "Incoming TLS connection from %s (sock=%d) is discarded "
-+		      "because listener is already destroyed",
-+		      pj_sockaddr_print(src_addr, addr, sizeof(addr), 3),
-+		      new_ssock));
-+
-+	    pj_ssl_sock_close(new_ssock);
-+	}
-+
-+	return PJ_FALSE;
-+    }
- 
-     if (accept_status != PJ_SUCCESS) {
--	if (listener && listener->tls_setting.on_accept_fail_cb) {
-+	if (listener->tls_setting.on_accept_fail_cb) {
- 	    pjsip_tls_on_accept_fail_param param;
- 	    pj_ssl_sock_info ssi;
- 
-@@ -1350,6 +1367,8 @@ static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock,
-     PJ_ASSERT_RETURN(new_ssock, PJ_TRUE);
- 
-     if (!listener->is_registered) {
-+	pj_ssl_sock_close(new_ssock);
-+
- 	if (listener->tls_setting.on_accept_fail_cb) {
- 	    pjsip_tls_on_accept_fail_param param;
- 	    pj_bzero(&param, sizeof(param));
-@@ -1401,6 +1420,8 @@ static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock,
- 			 ssl_info.grp_lock, &tls);
-     
-     if (status != PJ_SUCCESS) {
-+	pj_ssl_sock_close(new_ssock);
-+
- 	if (listener->tls_setting.on_accept_fail_cb) {
- 	    pjsip_tls_on_accept_fail_param param;
- 	    pj_bzero(&param, sizeof(param));
diff --git a/third-party/pjproject/patches/0111-ssl-premature-destroy.patch b/third-party/pjproject/patches/0111-ssl-premature-destroy.patch
deleted file mode 100644
index 9de2915..0000000
--- a/third-party/pjproject/patches/0111-ssl-premature-destroy.patch
+++ /dev/null
@@ -1,136 +0,0 @@
-From 68c69f516f95df1faa42e5647e9ce7cfdc41ac38 Mon Sep 17 00:00:00 2001
-From: Nanang Izzuddin <nanang at teluu.com>
-Date: Wed, 16 Jun 2021 12:15:29 +0700
-Subject: [PATCH 2/2] - Fix silly mistake: accepted active socket created
- without group lock in SSL socket. - Replace assertion with normal validation
- check of SSL socket instance in OpenSSL verification callback (verify_cb())
- to avoid crash, e.g: if somehow race condition with SSL socket destroy
- happens or OpenSSL application data index somehow gets corrupted.
-
----
- pjlib/src/pj/ssl_sock_imp_common.c |  3 +-
- pjlib/src/pj/ssl_sock_ossl.c       | 45 +++++++++++++++++++++++++-----
- 2 files changed, 40 insertions(+), 8 deletions(-)
-
-diff --git a/pjlib/src/pj/ssl_sock_imp_common.c b/pjlib/src/pj/ssl_sock_imp_common.c
-index bc468bcb3..c2b8a846b 100644
---- a/pjlib/src/pj/ssl_sock_imp_common.c
-+++ b/pjlib/src/pj/ssl_sock_imp_common.c
-@@ -927,6 +927,7 @@ static pj_bool_t asock_on_accept_complete (pj_activesock_t *asock,
- 
-     /* Create active socket */
-     pj_activesock_cfg_default(&asock_cfg);
-+    asock_cfg.grp_lock = ssock->param.grp_lock;
-     asock_cfg.async_cnt = ssock->param.async_cnt;
-     asock_cfg.concurrency = ssock->param.concurrency;
-     asock_cfg.whole_data = PJ_TRUE;
-@@ -942,7 +943,7 @@ static pj_bool_t asock_on_accept_complete (pj_activesock_t *asock,
- 	    goto on_return;
- 
- 	pj_grp_lock_add_ref(glock);
--	asock_cfg.grp_lock = ssock->param.grp_lock = glock;
-+	ssock->param.grp_lock = glock;
- 	pj_grp_lock_add_handler(ssock->param.grp_lock, ssock->pool, ssock,
- 				ssl_on_destroy);
-     }
-diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c
-index a95b339a5..56841f80a 100644
---- a/pjlib/src/pj/ssl_sock_ossl.c
-+++ b/pjlib/src/pj/ssl_sock_ossl.c
-@@ -327,7 +327,8 @@ static pj_status_t STATUS_FROM_SSL_ERR(char *action, pj_ssl_sock_t *ssock,
- 	ERROR_LOG("STATUS_FROM_SSL_ERR", err, ssock);
-     }
- 
--    ssock->last_err = err;
-+    if (ssock)
-+	ssock->last_err = err;
-     return GET_STATUS_FROM_SSL_ERR(err);
- }
- 
-@@ -344,7 +345,8 @@ static pj_status_t STATUS_FROM_SSL_ERR2(char *action, pj_ssl_sock_t *ssock,
-     /* Dig for more from OpenSSL error queue */
-     SSLLogErrors(action, ret, err, len, ssock);
- 
--    ssock->last_err = ssl_err;
-+    if (ssock)
-+	ssock->last_err = ssl_err;
-     return GET_STATUS_FROM_SSL_ERR(ssl_err);
- }
- 
-@@ -587,6 +589,13 @@ static pj_status_t init_openssl(void)
- 
-     /* Create OpenSSL application data index for SSL socket */
-     sslsock_idx = SSL_get_ex_new_index(0, "SSL socket", NULL, NULL, NULL);
-+	if (sslsock_idx == -1) {
-+		status = STATUS_FROM_SSL_ERR2("Init", NULL, -1, ERR_get_error(), 0);
-+		PJ_LOG(1,(THIS_FILE,
-+				  "Fatal error: failed to get application data index for "
-+				  "SSL socket"));
-+		return status;
-+	}
- 
-     return status;
- }
-@@ -614,21 +623,36 @@ static int password_cb(char *buf, int num, int rwflag, void *user_data)
- }
- 
- 
--/* SSL password callback. */
-+/* SSL certificate verification result callback.
-+ * Note that this callback seems to be always called from library worker
-+ * thread, e.g: active socket on_read_complete callback, which should have
-+ * already been equipped with race condition avoidance mechanism (should not
-+ * be destroyed while callback is being invoked).
-+ */
- static int verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
- {
--    pj_ssl_sock_t *ssock;
--    SSL *ossl_ssl;
-+    pj_ssl_sock_t *ssock = NULL;
-+    SSL *ossl_ssl = NULL;
-     int err;
- 
-     /* Get SSL instance */
-     ossl_ssl = X509_STORE_CTX_get_ex_data(x509_ctx, 
- 				    SSL_get_ex_data_X509_STORE_CTX_idx());
--    pj_assert(ossl_ssl);
-+    if (!ossl_ssl) {
-+	PJ_LOG(1,(THIS_FILE,
-+		  "SSL verification callback failed to get SSL instance"));
-+	goto on_return;
-+    }
- 
-     /* Get SSL socket instance */
-     ssock = SSL_get_ex_data(ossl_ssl, sslsock_idx);
--    pj_assert(ssock);
-+    if (!ssock) {
-+	/* SSL socket may have been destroyed */
-+	PJ_LOG(1,(THIS_FILE,
-+		  "SSL verification callback failed to get SSL socket "
-+		  "instance (sslsock_idx=%d).", sslsock_idx));
-+	goto on_return;
-+    }
- 
-     /* Store verification status */
-     err = X509_STORE_CTX_get_error(x509_ctx);
-@@ -706,6 +730,7 @@ static int verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
-     if (PJ_FALSE == ssock->param.verify_peer)
- 	preverify_ok = 1;
- 
-+on_return:
-     return preverify_ok;
- }
- 
-@@ -1213,6 +1238,12 @@ static void ssl_destroy(pj_ssl_sock_t *ssock)
- static void ssl_reset_sock_state(pj_ssl_sock_t *ssock)
- {
-     ossl_sock_t *ossock = (ossl_sock_t *)ssock;
-+
-+    /* Detach from SSL instance */
-+    if (ossock->ossl_ssl) {
-+	SSL_set_ex_data(ossock->ossl_ssl, sslsock_idx, NULL);
-+    }
-+
-     /**
-      * Avoid calling SSL_shutdown() if handshake wasn't completed.
-      * OpenSSL 1.0.2f complains if SSL_shutdown() is called during an
diff --git a/third-party/pjproject/pjproject-2.11.1.tar.bz2.md5 b/third-party/pjproject/pjproject-2.11.1.tar.bz2.md5
new file mode 100644
index 0000000..6a8a8ca
--- /dev/null
+++ b/third-party/pjproject/pjproject-2.11.1.tar.bz2.md5
@@ -0,0 +1,3 @@
+63de405e10da12bc5552afb5be454b2e  pjproject-2.11.1.tar.bz2
+d59a635a96587cb49a410e9285913b2a  pjproject-2.11.1.tar.gz
+ef2c0b4e7f0fa9f5dd895a091ceaa14b  pjproject-2.11.1.zip
diff --git a/third-party/versions.mak b/third-party/versions.mak
index fae41c6..943a5fb 100644
--- a/third-party/versions.mak
+++ b/third-party/versions.mak
@@ -1,2 +1,2 @@
 JANSSON_VERSION = 2.12
-PJPROJECT_VERSION = 2.10
+PJPROJECT_VERSION = 2.11.1

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17710
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: If610e36b66d6137a1bf40e2a47de27c94252efd8
Gerrit-Change-Number: 17710
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211222/1ece4241/attachment-0001.html>


More information about the asterisk-code-review mailing list