res_pjsip: Upgraded bundled pjsip to 2.13

Removed multiple patches.

Code chages in res_pjsip_pubsub due to changes in evsub.

Pjsip now calls on_evsub_state() before on_rx_refresh(),
so the sub tree deletion that used to take place in
on_evsub_state() now must take place in on_rx_refresh().

Additionally, pjsip now requires that you send the NOTIFY
from within on_rx_refresh(), otherwise it will assert
when going to send the 200 OK. The idea is that it will
look for this NOTIFY and cache it until after sending the
response in order to deal with the self-imposed message
mis-order. Asterisk previously dealt with this by pushing
the NOTIFY in on_rx_refresh(), but pjsip now forces us
to use it's method.

Changes were required to configure in order to detect
which way pjsip handles this as the two are not
compatible for the reasons mentioned above.

A corresponding change in testsuite is required in order
to deal with the small interal timing changes caused by
moving the NOTIFY send.

ASTERISK-30325

Change-Id: I50b00cac89d950d3511d7b250a1c641965d9fe7f
This commit is contained in:
Mike Bradeen 2023-01-20 15:50:44 -07:00 committed by Friendly Automation
parent d53c8fc4dc
commit 24e27a3c6e
14 changed files with 9892 additions and 12717 deletions

18159
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -594,6 +594,7 @@ AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_ENDPOINT_COMPACT_FORM], [PJSIP Compact Form Su
AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE], [PJSIP Transport Connection Reuse Disabling], [PJPROJECT], [pjsip])
AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_OAUTH_AUTHENTICATION], [PJSIP OAuth Authentication Support], [PJPROJECT], [pjsip])
AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_TLS_TRANSPORT_RESTART], [PJSIP TLS Transport Restart Support], [PJPROJECT], [pjsip])
AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_EVSUB_PENDING_NOTIFY], [PJSIP NOTIFY Required on SUBSCRIBE], [PJPROJECT], [pjsip])
fi
AST_EXT_LIB_SETUP([POPT], [popt], [popt])
@ -2533,6 +2534,18 @@ if test "$USE_PJPROJECT" != "no" ; then
AST_EXT_LIB_CHECK([PJSIP_AUTH_CLT_DEINIT], [pjsip], [pjsip_auth_clt_deinit], [pjsip.h], [$PJPROJECT_LIB], [$PJPROJECT_CFLAGS])
AST_EXT_LIB_CHECK([PJSIP_TSX_LAYER_FIND_TSX2], [pjsip], [pjsip_tsx_layer_find_tsx2], [pjsip.h], [$PJPROJECT_LIB], [$PJPROJECT_CFLAGS])
AST_EXT_LIB_CHECK([PJSIP_TLS_TRANSPORT_RESTART], [pjsip], [pjsip_tls_transport_restart], [pjsip.h], [$PJPROJECT_LIB], [$PJPROJECT_CFLAGS])
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pending_notify in evsub.c" >&5
$as_echo_n "checking for pending_notify in evsub... " >&6; }
pending_notify=$(${SED} -n -r -e '/^struct\s+pjsip_evsub/,/^\s+void\s+*mod_data/!d ; /pending_notify/p' $(find $PJSIP_EVSUB_PENDING_NOTIFY_DIR -name evsub.c))
if test -n "$pending_notify" ; then
AC_DEFINE(HAVE_PJSIP_EVSUB_PENDING_NOTIFY, 1, [Define to 1 if evsub requires a NOTIFY on SUBSCRIBE.])
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
fi

View File

@ -19,14 +19,19 @@
of a mutex to its initializer. */
#undef CAN_COMPARE_MUTEX_TO_INIT_VALUE
/* Define to 1 if the `closedir' function returns void instead of int. */
/* Define to 1 if the `closedir' function returns void instead of `int'. */
#undef CLOSEDIR_VOID
/* Some configure tests will unexpectedly fail if configure is run by a
non-root user. These may be able to be tested at runtime. */
#undef CONFIGURE_RAN_AS_ROOT
/* Define to 1 if using 'alloca.c'. */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if anonymous semaphores work. */
@ -38,10 +43,11 @@
/* Define to 1 if you have the `acosl' function. */
#undef HAVE_ACOSL
/* Define to 1 if you have 'alloca', as a function or macro. */
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define to 1 if <alloca.h> works. */
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the Advanced Linux Sound Architecture library. */
@ -502,12 +508,12 @@
/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the <minix/config.h> header file. */
#undef HAVE_MINIX_CONFIG_H
/* Define to 1 if you have the mISDN user library. */
#undef HAVE_MISDN
@ -644,6 +650,9 @@
/* Define to 1 if PJPROJECT has the PJSIP EVSUB Group Lock support feature. */
#undef HAVE_PJSIP_EVSUB_GRP_LOCK
/* Define to 1 if evsub requires a NOTIFY on SUBSCRIBE. */
#undef HAVE_PJSIP_EVSUB_PENDING_NOTIFY
/* Define to 1 if PJPROJECT has the PJSIP External Resolver Support feature.
*/
#undef HAVE_PJSIP_EXTERNAL_RESOLVER
@ -1271,9 +1280,6 @@
/* Define to 1 if you have the `vprintf' function. */
#undef HAVE_VPRINTF
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Define to 1 if you have the <winsock2.h> header file. */
#undef HAVE_WINSOCK2_H
@ -1431,13 +1437,10 @@
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This
macro is obsolete. */
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
@ -1450,93 +1453,32 @@
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable general extensions on macOS. */
#ifndef _DARWIN_C_SOURCE
# undef _DARWIN_C_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable X/Open compliant socket functions that do not require linking
with -lxnet on HP-UX 11.11. */
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
# undef _HPUX_ALT_XOPEN_SOCKET_API
#endif
/* Identify the host operating system as Minix.
This macro does not affect the system headers' behavior.
A future release of Autoconf may stop defining this macro. */
#ifndef _MINIX
# undef _MINIX
#endif
/* Enable general extensions on NetBSD.
Enable NetBSD compatibility extensions on Minix. */
#ifndef _NETBSD_SOURCE
# undef _NETBSD_SOURCE
#endif
/* Enable OpenBSD compatibility extensions on NetBSD.
Oddly enough, this does nothing on OpenBSD. */
#ifndef _OPENBSD_SOURCE
# undef _OPENBSD_SOURCE
#endif
/* Define to 1 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_SOURCE
# undef _POSIX_SOURCE
#endif
/* Define to 2 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_1_SOURCE
# undef _POSIX_1_SOURCE
#endif
/* Enable POSIX-compatible threading on Solaris. */
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
# undef __STDC_WANT_IEC_60559_BFP_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# undef __STDC_WANT_IEC_60559_DFP_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# undef __STDC_WANT_IEC_60559_TYPES_EXT__
#endif
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
#ifndef __STDC_WANT_LIB_EXT2__
# undef __STDC_WANT_LIB_EXT2__
#endif
/* Enable extensions specified by ISO/IEC 24747:2009. */
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
# undef __STDC_WANT_MATH_SPEC_FUNCS__
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable X/Open extensions. Define to 500 only if necessary
to make mbstate_t available. */
#ifndef _XOPEN_SOURCE
# undef _XOPEN_SOURCE
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Define to 1 if running on Darwin. */
#undef _DARWIN_UNLIMITED_SELECT
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
@ -1554,6 +1496,16 @@
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to 1 if on MINIX. */
#undef _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
@ -1575,7 +1527,7 @@
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
/* Define as a signed integer type capable of holding a process identifier. */
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define to `unsigned int' if <sys/types.h> does not define. */

View File

@ -4,13 +4,19 @@
#define MENUSELECT_AUTOCONFIG_H
/* Define to 1 if using 'alloca.c'. */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if you have 'alloca', as a function or macro. */
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define to 1 if <alloca.h> works. */
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the `asprintf' function. */
@ -31,6 +37,9 @@
/* Define if your system has the LIBXML2 libraries. */
#undef HAVE_LIBXML2
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the ncurses library. */
#undef HAVE_NCURSES
@ -43,9 +52,6 @@
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
@ -111,9 +117,7 @@
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to `unsigned int' if <sys/types.h> does not define. */

3418
menuselect/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -3838,35 +3838,20 @@ static void set_state_terminated(struct ast_sip_subscription *sub)
*
*/
/*!
* \brief PJSIP callback when underlying SIP subscription changes state
*
* Although this function is called for every state change, we only care
* about the TERMINATED state, and only when we're actually processing the final
* notify (SIP_SUB_TREE_TERMINATE_IN_PROGRESS) OR when a transmission failure
* occurs (PJSIP_EVENT_TSX_STATE). In this case, we do all the subscription tree
* cleanup tasks and decrement the evsub reference.
/* The code in this function was previously in pubsub_on_evsub_state. As of
* pjsip 2.13 pubsub_on_evsub_state is called before pubsub_on_rx_refresh, so
* if we clean the sub tree in pubsub_on_evsub_state it won't be available in
* pubsub_on_rx_refresh. This means we won't be able to build or send the
* corresponding NOTIFY (which also causes pjsip to assert.)
* If HAVE_PJSIP_EVSUB_PENDING_NOTIFY is set based on configuration, this will
* be called from pubsub_on_rx_refresh. If not set, the result is the legacy
* behavior of calling this from pubsub_on_evsub_state.
*/
static void pubsub_on_evsub_state(pjsip_evsub *evsub, pjsip_event *event)
{
struct sip_subscription_tree *sub_tree =
pjsip_evsub_get_mod_data(evsub, pubsub_module.id);
static void clean_sub_tree(pjsip_evsub *evsub){
ast_debug(3, "evsub %p state %s event %s sub_tree %p sub_tree state %s\n", evsub,
pjsip_evsub_get_state_name(evsub), pjsip_event_str(event->type), sub_tree,
(sub_tree ? sub_tree_state_description[sub_tree->state] : "UNKNOWN"));
if (!sub_tree || pjsip_evsub_get_state(evsub) != PJSIP_EVSUB_STATE_TERMINATED) {
return;
}
/* It's easier to write this as what we WANT to process, then negate it. */
if (!(sub_tree->state == SIP_SUB_TREE_TERMINATE_IN_PROGRESS
|| (event->type == PJSIP_EVENT_TSX_STATE && sub_tree->state == SIP_SUB_TREE_NORMAL)
)) {
ast_debug(3, "Do nothing.\n");
return;
}
struct sip_subscription_tree *sub_tree;
sub_tree = pjsip_evsub_get_mod_data(evsub, pubsub_module.id);
if (sub_tree->expiration_task) {
char task_name[256];
@ -3899,6 +3884,45 @@ static void pubsub_on_evsub_state(pjsip_evsub *evsub, pjsip_event *event)
ao2_ref(sub_tree, -1);
}
/*!
* \brief PJSIP callback when underlying SIP subscription changes state
*
* Although this function is called for every state change, we only care
* about the TERMINATED state, and only when we're actually processing the final
* notify (SIP_SUB_TREE_TERMINATE_IN_PROGRESS) OR when a transmission failure
* occurs (PJSIP_EVENT_TSX_STATE). In this case, we do all the subscription tree
* cleanup tasks and decrement the evsub reference.
*/
static void pubsub_on_evsub_state(pjsip_evsub *evsub, pjsip_event *event)
{
struct sip_subscription_tree *sub_tree =
pjsip_evsub_get_mod_data(evsub, pubsub_module.id);
ast_debug(3, "evsub %p state %s event %s sub_tree %p sub_tree state %s\n", evsub,
pjsip_evsub_get_state_name(evsub), pjsip_event_str(event->type), sub_tree,
(sub_tree ? sub_tree_state_description[sub_tree->state] : "UNKNOWN"));
if (!sub_tree || pjsip_evsub_get_state(evsub) != PJSIP_EVSUB_STATE_TERMINATED) {
return;
}
/* It's easier to write this as what we WANT to process, then negate it. */
if (!(sub_tree->state == SIP_SUB_TREE_TERMINATE_IN_PROGRESS
|| (event->type == PJSIP_EVENT_TSX_STATE && sub_tree->state == SIP_SUB_TREE_NORMAL)
)) {
ast_debug(3, "Do nothing.\n");
return;
}
#ifndef HAVE_PJSIP_EVSUB_PENDING_NOTIFY
/* for pjproject <2.13, this cleanup occurs here. For >=2.13, pubsub_on_evsub_state
is called before pubsub_on_rx_refresh and so must be cleaned there.*/
clean_sub_tree(evsub);
#endif
}
static int pubsub_on_refresh_timeout(void *userdata)
{
struct sip_subscription_tree *sub_tree = userdata;
@ -4107,16 +4131,37 @@ static void pubsub_on_rx_refresh(pjsip_evsub *evsub, pjsip_rx_data *rdata,
subscription_persistence_update(sub_tree, rdata, SUBSCRIPTION_PERSISTENCE_REFRESHED);
#ifdef HAVE_PJSIP_EVSUB_PENDING_NOTIFY
/* As of pjsip 2.13, the NOTIFY has to be sent within this function as pjproject now
requires it. Previously this would have caused an early NOTIFY to go out before the
SUBSCRIBE's 200 OK. The previous solution was to push the NOTIFY, but now pjproject
looks for the NOTIFY on send and delays it until after it auto-replies.
If the NOTIFY is not there when it looks to send, pjproject will assert. */
serialized_pubsub_on_refresh_timeout(sub_tree);
#else
if (ast_sip_push_task(sub_tree->serializer, serialized_pubsub_on_refresh_timeout, ao2_bump(sub_tree))) {
/* If we can't push the NOTIFY refreshing task...we'll just go with it. */
ast_log(LOG_ERROR, "Failed to push task to send NOTIFY.\n");
sub_tree->state = SIP_SUB_TREE_NORMAL;
ao2_ref(sub_tree, -1);
}
#endif
if (sub_tree->is_list) {
pj_list_insert_before(res_hdr, create_require_eventlist(rdata->tp_info.pool));
}
#ifdef HAVE_PJSIP_EVSUB_PENDING_NOTIFY
/* for pjproject <2.13, this cleanup occurs in pubsub_on_evsub_state. For >=2.13,
pubsub_on_rx_refresh is called after pubsub_on_evsub_state and so the tree must be
cleaned here. */
if( pjsip_evsub_get_state(evsub) == PJSIP_EVSUB_STATE_TERMINATED &&
sub_tree->state == SIP_SUB_TREE_TERMINATE_PENDING ) {
clean_sub_tree(evsub);
}
#endif
}
static void pubsub_on_rx_notify(pjsip_evsub *evsub, pjsip_rx_data *rdata, int *p_st_code,

View File

@ -132,6 +132,7 @@ AC_DEFUN([_PJPROJECT_CONFIGURE],
AC_DEFINE([HAVE_PJSIP_OAUTH_AUTHENTICATION], 1, [Define if your system has HAVE_PJSIP_OAUTH_AUTHENTICATION declared])
AC_DEFINE([HAVE_PJPROJECT_ON_VALID_ICE_PAIR_CALLBACK], 1, [Define if your system has the on_valid_pair pjnath callback.])
AC_DEFINE([HAVE_PJSIP_TLS_TRANSPORT_RESTART], 1, [Define if your system has pjsip_tls_transport_restart support.])
AC_DEFINE([HAVE_PJSIP_EVSUB_PENDING_NOTIFY], 1, [Define to 1 if evsub requires a NOTIFY on SUBSCRIBE.])
AC_SUBST([PJPROJECT_BUNDLED])
AC_SUBST([PJPROJECT_BUNDLED_OOT])

View File

@ -7,10 +7,11 @@ index 4bc464f8c..80681d961 100644
include $(PJDIR)/version.mak
export PJ_DIR := $(PJDIR)
@@ -41,19 +40,6 @@ export APP_THIRD_PARTY_EXT :=
@@ -42,21 +41,6 @@ export APP_THIRD_PARTY_EXT :=
export APP_THIRD_PARTY_LIBS :=
export APP_THIRD_PARTY_LIB_FILES :=
-ifneq (@ac_no_srtp@,1)
-ifneq (@ac_external_srtp@,0)
-# External SRTP library
-APP_THIRD_PARTY_EXT += -l@ac_external_srtp_lib@
@ -23,11 +24,12 @@ index 4bc464f8c..80681d961 100644
-APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libsrtp.$(SHLIB_SUFFIX).$(PJ_VERSION_MAJOR) $(PJ_DIR)/third_party/lib/libsrtp.$(SHLIB_SUFFIX)
-endif
-endif
-endif
-
ifeq (@ac_pjmedia_resample@,libresample)
APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample-$(LIB_SUFFIX)
ifeq ($(PJ_SHARED_LIBRARIES),)
@@ -70,102 +56,6 @@ APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFI
@@ -73,102 +57,6 @@ APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libresample.$(SHLIB_SUFFI
endif
endif

View File

@ -1,413 +0,0 @@
commit 8e95490e37938f45d9d812905246036c3185b94f
Author: Riza Sulistyo <trengginas@users.noreply.github.com>
Date: Thu Mar 24 12:53:03 2022 +0700
Add compile time option to allow multiple Authorization header (#3010)
diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h
index dfd9ce977..ccce6ed01 100644
--- a/pjsip/include/pjsip/sip_config.h
+++ b/pjsip/include/pjsip/sip_config.h
@@ -1280,6 +1280,18 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)
# define PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY 1
#endif
+/**
+ * Allow client to send multiple Authorization header when receiving multiple
+ * WWW-Authenticate header fields. If this is disabled, the stack will send
+ * Authorization header field containing credentials that match the
+ * topmost header field.
+ *
+ * Default is 0
+ */
+#ifndef PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER
+# define PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER 0
+#endif
+
/*****************************************************************************
* SIP Event framework and presence settings.
*/
@@ -1458,6 +1470,11 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)
# define PJSIP_INV_ACCEPT_UNKNOWN_BODY PJ_FALSE
#endif
+/**
+ * Dump configuration to log with verbosity equal to info(3).
+ */
+PJ_DECL(void) pjsip_dump_config(void);
+
PJ_END_DECL
/**
diff --git a/pjsip/src/pjsip/sip_auth_client.c b/pjsip/src/pjsip/sip_auth_client.c
index 35460d01e..ab1a0cd87 100644
--- a/pjsip/src/pjsip/sip_auth_client.c
+++ b/pjsip/src/pjsip/sip_auth_client.c
@@ -1367,7 +1367,7 @@ PJ_DEF(pj_status_t) pjsip_auth_clt_reinit_req( pjsip_auth_clt_sess *sess,
chal_cnt = 0;
auth_cnt = 0;
last_auth_err = PJSIP_EAUTHNOAUTH;
- while (hdr != &rdata->msg_info.msg->hdr && auth_cnt == 0) {
+ while (hdr != &rdata->msg_info.msg->hdr) {
pjsip_cached_auth *cached_auth;
const pjsip_www_authenticate_hdr *hchal;
pjsip_authorization_hdr *hauth;
@@ -1431,6 +1431,11 @@ PJ_DEF(pj_status_t) pjsip_auth_clt_reinit_req( pjsip_auth_clt_sess *sess,
/* Process next header. */
hdr = hdr->next;
auth_cnt++;
+
+#if defined(PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER) && \
+ PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER==0
+ break;
+#endif
}
/* Check if challenge is present */
diff --git a/pjsip/src/pjsip/sip_config.c b/pjsip/src/pjsip/sip_config.c
index 957f9fad4..6920b3dfe 100644
--- a/pjsip/src/pjsip/sip_config.c
+++ b/pjsip/src/pjsip/sip_config.c
@@ -19,6 +19,9 @@
*/
#include <pjsip/sip_config.h>
+#include <pj/log.h>
+
+static const char *id = "sip_config.c";
/* pjsip configuration instance, initialized with default values */
pjsip_cfg_t pjsip_sip_cfg_var =
@@ -65,6 +68,195 @@ pjsip_cfg_t pjsip_sip_cfg_var =
}
};
+PJ_DEF(void) pjsip_dump_config(void)
+{
+ PJ_LOG(3, (id, "Dumping PJSIP configurations:"));
+ PJ_LOG(3, (id, " PJSIP_MAX_DIALOG_COUNT : %d",
+ PJSIP_MAX_DIALOG_COUNT));
+ PJ_LOG(3, (id, " PJSIP_MAX_TRANSPORTS : %d",
+ PJSIP_MAX_TRANSPORTS));
+ PJ_LOG(3, (id, " PJSIP_TPMGR_HTABLE_SIZE : %d",
+ PJSIP_TPMGR_HTABLE_SIZE));
+ PJ_LOG(3, (id, " PJSIP_MAX_URL_SIZE : %d",
+ PJSIP_MAX_URL_SIZE));
+ PJ_LOG(3, (id, " PJSIP_MAX_MODULE : %d",
+ PJSIP_MAX_MODULE));
+ PJ_LOG(3, (id, " PJSIP_MAX_PKT_LEN : %d",
+ PJSIP_MAX_PKT_LEN));
+ PJ_LOG(3, (id, " PJSIP_HANDLE_EVENTS_HAS_SLEEP_ON_ERR : %d",
+ PJSIP_HANDLE_EVENTS_HAS_SLEEP_ON_ERR));
+ PJ_LOG(3, (id, " PJSIP_ACCEPT_MULTIPLE_SDP_ANSWERS : %d",
+ PJSIP_ACCEPT_MULTIPLE_SDP_ANSWERS));
+ PJ_LOG(3, (id, " PJSIP_UDP_SIZE_THRESHOLD : %d",
+ PJSIP_UDP_SIZE_THRESHOLD));
+ PJ_LOG(3, (id, " PJSIP_INCLUDE_ALLOW_HDR_IN_DLG : %d",
+ PJSIP_INCLUDE_ALLOW_HDR_IN_DLG));
+ PJ_LOG(3, (id, " PJSIP_SAFE_MODULE : %d",
+ PJSIP_SAFE_MODULE));
+ PJ_LOG(3, (id, " PJSIP_CHECK_VIA_SENT_BY : %d",
+ PJSIP_CHECK_VIA_SENT_BY));
+ PJ_LOG(3, (id, " PJSIP_UNESCAPE_IN_PLACE : %d",
+ PJSIP_UNESCAPE_IN_PLACE));
+ PJ_LOG(3, (id, " PJSIP_MAX_NET_EVENTS : %d",
+ PJSIP_MAX_NET_EVENTS));
+ PJ_LOG(3, (id, " PJSIP_MAX_TIMED_OUT_ENTRIES : %d",
+ PJSIP_MAX_TIMED_OUT_ENTRIES));
+ PJ_LOG(3, (id, " PJSIP_TRANSPORT_IDLE_TIME : %d",
+ PJSIP_TRANSPORT_IDLE_TIME));
+ PJ_LOG(3, (id, " PJSIP_TRANSPORT_SERVER_IDLE_TIME : %d",
+ PJSIP_TRANSPORT_SERVER_IDLE_TIME));
+ PJ_LOG(3, (id, " PJSIP_MAX_TRANSPORT_USAGE : %d",
+ PJSIP_MAX_TRANSPORT_USAGE));
+ PJ_LOG(3, (id, " PJSIP_TCP_TRANSPORT_BACKLOG : %d",
+ PJSIP_TCP_TRANSPORT_BACKLOG));
+ PJ_LOG(3, (id, " PJSIP_TCP_TRANSPORT_REUSEADDR : %d",
+ PJSIP_TCP_TRANSPORT_REUSEADDR));
+ PJ_LOG(3, (id, " PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER : %d",
+ PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER));
+ PJ_LOG(3, (id, " PJSIP_TLS_TRANSPORT_DONT_CREATE_LISTENER : %d",
+ PJSIP_TLS_TRANSPORT_DONT_CREATE_LISTENER));
+ PJ_LOG(3, (id, " PJSIP_TCP_KEEP_ALIVE_INTERVAL : %d",
+ PJSIP_TCP_KEEP_ALIVE_INTERVAL));
+ PJ_LOG(3, (id, " PJSIP_POOL_INC_TRANSPORT : %d",
+ PJSIP_POOL_INC_TRANSPORT));
+ PJ_LOG(3, (id, " PJSIP_POOL_LEN_TDATA : %d",
+ PJSIP_POOL_LEN_TDATA));
+ PJ_LOG(3, (id, " PJSIP_POOL_INC_TDATA : %d",
+ PJSIP_POOL_INC_TDATA));
+ PJ_LOG(3, (id, " PJSIP_POOL_LEN_UA : %d",
+ PJSIP_POOL_LEN_UA));
+ PJ_LOG(3, (id, " PJSIP_POOL_INC_UA : %d",
+ PJSIP_POOL_INC_UA));
+ PJ_LOG(3, (id, " PJSIP_POOL_EVSUB_LEN : %d",
+ PJSIP_POOL_EVSUB_LEN));
+ PJ_LOG(3, (id, " PJSIP_POOL_EVSUB_INC : %d",
+ PJSIP_POOL_EVSUB_INC));
+ PJ_LOG(3, (id, " PJSIP_MAX_FORWARDS_VALUE : %d",
+ PJSIP_MAX_FORWARDS_VALUE));
+ PJ_LOG(3, (id, " PJSIP_RFC3261_BRANCH_ID : %s",
+ PJSIP_RFC3261_BRANCH_ID));
+ PJ_LOG(3, (id, " PJSIP_RFC3261_BRANCH_LEN : %d",
+ PJSIP_RFC3261_BRANCH_LEN));
+ PJ_LOG(3, (id, " PJSIP_POOL_TSX_LAYER_LEN : %d",
+ PJSIP_POOL_TSX_LAYER_LEN));
+ PJ_LOG(3, (id, " PJSIP_POOL_TSX_LAYER_INC : %d",
+ PJSIP_POOL_TSX_LAYER_INC));
+ PJ_LOG(3, (id, " PJSIP_POOL_TSX_LEN : %d",
+ PJSIP_POOL_TSX_LEN));
+ PJ_LOG(3, (id, " PJSIP_POOL_TSX_INC : %d",
+ PJSIP_POOL_TSX_INC));
+ PJ_LOG(3, (id, " PJSIP_TSX_1XX_RETRANS_DELAY : %d",
+ PJSIP_TSX_1XX_RETRANS_DELAY));
+ PJ_LOG(3, (id, " PJSIP_TSX_UAS_CONTINUE_ON_TP_ERROR : %d",
+ PJSIP_TSX_UAS_CONTINUE_ON_TP_ERROR));
+ PJ_LOG(3, (id, " PJSIP_MAX_TSX_KEY_LEN : %d",
+ PJSIP_MAX_TSX_KEY_LEN));
+ PJ_LOG(3, (id, " PJSIP_POOL_LEN_USER_AGENT : %d",
+ PJSIP_POOL_LEN_USER_AGENT));
+ PJ_LOG(3, (id, " PJSIP_POOL_INC_USER_AGENT : %d",
+ PJSIP_POOL_INC_USER_AGENT));
+ PJ_LOG(3, (id, " PJSIP_MAX_BRANCH_LEN : %d",
+ PJSIP_MAX_HNAME_LEN));
+ PJ_LOG(3, (id, " PJSIP_POOL_LEN_DIALOG : %d",
+ PJSIP_POOL_LEN_DIALOG));
+ PJ_LOG(3, (id, " PJSIP_POOL_INC_DIALOG : %d",
+ PJSIP_POOL_INC_DIALOG));
+ PJ_LOG(3, (id, " PJSIP_MAX_HEADER_TYPES : %d",
+ PJSIP_MAX_HEADER_TYPES));
+ PJ_LOG(3, (id, " PJSIP_MAX_URI_TYPES : %d",
+ PJSIP_MAX_URI_TYPES));
+ PJ_LOG(3, (id, " PJSIP_AUTH_HEADER_CACHING : %d",
+ PJSIP_AUTH_HEADER_CACHING));
+ PJ_LOG(3, (id, " PJSIP_AUTH_AUTO_SEND_NEXT : %d",
+ PJSIP_AUTH_AUTO_SEND_NEXT));
+ PJ_LOG(3, (id, " PJSIP_AUTH_QOP_SUPPORT : %d",
+ PJSIP_AUTH_QOP_SUPPORT));
+ PJ_LOG(3, (id, " PJSIP_MAX_STALE_COUNT : %d",
+ PJSIP_MAX_STALE_COUNT));
+ PJ_LOG(3, (id, " PJSIP_HAS_DIGEST_AKA_AUTH : %d",
+ PJSIP_HAS_DIGEST_AKA_AUTH));
+ PJ_LOG(3, (id, " PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH : %d",
+ PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH));
+ PJ_LOG(3, (id, " PJSIP_REGISTER_ALLOW_EXP_REFRESH : %d",
+ PJSIP_REGISTER_ALLOW_EXP_REFRESH));
+ PJ_LOG(3, (id, " PJSIP_AUTH_CACHED_POOL_MAX_SIZE : %d",
+ PJSIP_AUTH_CACHED_POOL_MAX_SIZE));
+ PJ_LOG(3, (id, " PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY : %d",
+ PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY));
+ PJ_LOG(3, (id, " PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER : %d",
+ PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER));
+ PJ_LOG(3, (id, " PJSIP_EVSUB_TIME_UAC_REFRESH : %d",
+ PJSIP_EVSUB_TIME_UAC_REFRESH));
+ PJ_LOG(3, (id, " PJSIP_PUBLISHC_DELAY_BEFORE_REFRESH : %d",
+ PJSIP_PUBLISHC_DELAY_BEFORE_REFRESH));
+ PJ_LOG(3, (id, " PJSIP_EVSUB_TIME_UAC_TERMINATE : %d",
+ PJSIP_EVSUB_TIME_UAC_TERMINATE));
+ PJ_LOG(3, (id, " PJSIP_EVSUB_TIME_UAC_WAIT_NOTIFY : %d",
+ PJSIP_EVSUB_TIME_UAC_WAIT_NOTIFY));
+ PJ_LOG(3, (id, " PJSIP_PRES_DEFAULT_EXPIRES : %d",
+ PJSIP_PRES_DEFAULT_EXPIRES));
+ PJ_LOG(3, (id, " PJSIP_PRES_BAD_CONTENT_RESPONSE : %d",
+ PJSIP_PRES_BAD_CONTENT_RESPONSE));
+ PJ_LOG(3, (id, " PJSIP_PRES_PIDF_ADD_TIMESTAMP : %d",
+ PJSIP_PRES_PIDF_ADD_TIMESTAMP));
+ PJ_LOG(3, (id, " PJSIP_SESS_TIMER_DEF_SE : %d",
+ PJSIP_SESS_TIMER_DEF_SE));
+ PJ_LOG(3, (id, " PJSIP_SESS_TIMER_RETRY_DELAY : %d",
+ PJSIP_SESS_TIMER_RETRY_DELAY));
+ PJ_LOG(3, (id, " PJSIP_PUBLISHC_QUEUE_REQUEST : %d",
+ PJSIP_PUBLISHC_QUEUE_REQUEST));
+ PJ_LOG(3, (id, " PJSIP_MWI_DEFAULT_EXPIRES : %d",
+ PJSIP_MWI_DEFAULT_EXPIRES));
+ PJ_LOG(3, (id, " PJSIP_HAS_TX_DATA_LIST : %d",
+ PJSIP_HAS_TX_DATA_LIST));
+ PJ_LOG(3, (id, " PJSIP_INV_ACCEPT_UNKNOWN_BODY : %d",
+ PJSIP_INV_ACCEPT_UNKNOWN_BODY));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.allow_port_in_fromto_hdr : %d",
+ pjsip_cfg()->endpt.allow_port_in_fromto_hdr));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.accept_replace_in_early_state : %d",
+ pjsip_cfg()->endpt.accept_replace_in_early_state));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.allow_tx_hash_in_uri : %d",
+ pjsip_cfg()->endpt.allow_tx_hash_in_uri));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.disable_rport : %d",
+ pjsip_cfg()->endpt.disable_rport));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.disable_tcp_switch : %d",
+ pjsip_cfg()->endpt.disable_tcp_switch));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.disable_tls_switch : %d",
+ pjsip_cfg()->endpt.disable_tls_switch));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.follow_early_media_fork : %d",
+ pjsip_cfg()->endpt.follow_early_media_fork));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.req_has_via_alias : %d",
+ pjsip_cfg()->endpt.req_has_via_alias));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.resolve_hostname_to_get_interface:%d",
+ pjsip_cfg()->endpt.resolve_hostname_to_get_interface));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.disable_secure_dlg_check : %d",
+ pjsip_cfg()->endpt.disable_secure_dlg_check));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.use_compact_form : %d",
+ pjsip_cfg()->endpt.use_compact_form));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.accept_multiple_sdp_answers : %d",
+ pjsip_cfg()->endpt.accept_multiple_sdp_answers));
+ PJ_LOG(3, (id, " pjsip_cfg()->endpt.keep_inv_after_tsx_timeout : %d",
+ pjsip_cfg()->endpt.keep_inv_after_tsx_timeout));
+ PJ_LOG(3, (id, " pjsip_cfg()->tsx.max_count : %d",
+ pjsip_cfg()->tsx.max_count));
+ PJ_LOG(3, (id, " pjsip_cfg()->tsx.t1 : %d",
+ pjsip_cfg()->tsx.t1));
+ PJ_LOG(3, (id, " pjsip_cfg()->tsx.t2 : %d",
+ pjsip_cfg()->tsx.t2));
+ PJ_LOG(3, (id, " pjsip_cfg()->tsx.t4 : %d",
+ pjsip_cfg()->tsx.t4));
+ PJ_LOG(3, (id, " pjsip_cfg()->td : %d",
+ pjsip_cfg()->tsx.td));
+ PJ_LOG(3, (id, " pjsip_cfg()->regc.check_contact : %d",
+ pjsip_cfg()->regc.check_contact));
+ PJ_LOG(3, (id, " pjsip_cfg()->regc.add_xuid_param : %d",
+ pjsip_cfg()->regc.add_xuid_param));
+ PJ_LOG(3, (id, " pjsip_cfg()->tcp.keep_alive_interval : %d",
+ pjsip_cfg()->tcp.keep_alive_interval));
+ PJ_LOG(3, (id, " pjsip_cfg()->tls.keep_alive_interval : %d",
+ pjsip_cfg()->tls.keep_alive_interval));
+}
+
#ifdef PJ_DLL
PJ_DEF(pjsip_cfg_t*) pjsip_cfg(void)
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index c437011b5..343316b56 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -3443,8 +3443,10 @@ PJ_DEF(void) pjsua_dump(pj_bool_t detail)
old_decor = pj_log_get_decor();
pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR));
- if (detail)
+ if (detail) {
pj_dump_config();
+ pjsip_dump_config();
+ }
pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail);
diff --git a/tests/pjsua/inc_sip.py b/tests/pjsua/inc_sip.py
index f7e64816e..2cc1a17a8 100644
--- a/tests/pjsua/inc_sip.py
+++ b/tests/pjsua/inc_sip.py
@@ -306,9 +306,11 @@ class RecvfromTransaction:
body = None
# Pattern to be expected on pjsua when receiving the response
expect = ""
+ # Required config
+ pj_config = ""
def __init__(self, title, resp_code, check_cseq=True,
- include=[], exclude=[], cmds=[], resp_hdr=[], resp_body=None, expect=""):
+ include=[], exclude=[], cmds=[], resp_hdr=[], resp_body=None, expect="", pj_config=""):
self.title = title
self.cmds = cmds
self.include = include
@@ -317,6 +319,7 @@ class RecvfromTransaction:
self.resp_hdr = resp_hdr
self.body = resp_body
self.expect = expect
+ self.pj_config=pj_config
class RecvfromCfg:
@@ -328,15 +331,18 @@ class RecvfromCfg:
transaction = None
# Use TCP?
tcp = False
+ # Required config
+ pj_config = ""
# Note:
# Any "$PORT" string in the pjsua_args will be replaced
# by server port
- def __init__(self, name, pjsua_args, transaction, tcp=False):
+ def __init__(self, name, pjsua_args, transaction, tcp=False, pj_config=""):
self.name = name
self.inst_param = cfg.InstanceParam("pjsua", pjsua_args)
self.transaction = transaction
self.tcp=tcp
+ self.pj_config=pj_config
diff --git a/tests/pjsua/mod_recvfrom.py b/tests/pjsua/mod_recvfrom.py
index 918006aff..4305bfb42 100644
--- a/tests/pjsua/mod_recvfrom.py
+++ b/tests/pjsua/mod_recvfrom.py
@@ -18,10 +18,20 @@ def test_func(test):
local_port=srv_port,
tcp=cfg_file.recvfrom_cfg.tcp)
+ config = pjsua.get_config(cfg_file.recvfrom_cfg.pj_config)
+ print "Config : " + config
+
last_cseq = 0
last_method = ""
last_call_id = ""
for t in cfg_file.recvfrom_cfg.transaction:
+ # Check if transaction requires configuration
+ if t.pj_config != "":
+ r = re.compile(t.pj_config, re.I)
+ if r.search(config) == None:
+ print "Configuration : " + t.pj_config + " not found, skipping"
+ continue
+
# Print transaction title
if t.title != "":
dlg.trace(t.title)
diff --git a/tests/pjsua/run.py b/tests/pjsua/run.py
index 35b00dec5..cffc38470 100644
--- a/tests/pjsua/run.py
+++ b/tests/pjsua/run.py
@@ -249,6 +249,10 @@ class Expect(threading.Thread):
time.sleep(0.01)
return None
+ def get_config(self, key_config):
+ self.send("dd")
+ line = self.expect(key_config);
+ return line
def sync_stdout(self):
if not self.use_telnet:
diff --git a/tests/pjsua/scripts-recvfrom/215_reg_good_multi_ok.py b/tests/pjsua/scripts-recvfrom/215_reg_good_multi_ok.py
index a98b8b1d8..909ba229b 100644
--- a/tests/pjsua/scripts-recvfrom/215_reg_good_multi_ok.py
+++ b/tests/pjsua/scripts-recvfrom/215_reg_good_multi_ok.py
@@ -14,16 +14,27 @@ req1 = sip.RecvfromTransaction("Initial registration", 401,
expect="SIP/2.0 401"
)
-req2 = sip.RecvfromTransaction("Registration retry with auth", 200,
+req2 = sip.RecvfromTransaction("Registration retry with auth (not allowed multiple auth)", 200,
include=["REGISTER sip",
- # Must only have 1 Auth hdr since #2887
"Authorization:", # [\\s\\S]+Authorization:"
"realm=\"python1\"", # "realm=\"python2\"",
"username=\"theuser1\"", # "username=\"theuser2\"",
"nonce=\"1234\"", # "nonce=\"6789\"",
"response="],
- expect="registration success"
+ expect="registration success",
+ pj_config="PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER.*: 0"
)
+req3 = sip.RecvfromTransaction("Registration retry with auth (allowed multiple auth)", 200,
+ include=["REGISTER sip",
+ "Authorization:[\\s\\S]+Authorization:", # Must have 2 Auth hdrs
+ "realm=\"python1\"", "realm=\"python2\"",
+ "username=\"theuser1\"", "username=\"theuser2\"",
+ "nonce=\"1234\"", "nonce=\"6789\"",
+ "response="],
+ expect="registration success",
+ pj_config="PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER.*: 1"
+ )
+
recvfrom_cfg = sip.RecvfromCfg("Multiple authentication challenges",
- pjsua, [req1, req2])
+ pjsua, [req1, req2, req3], pj_config="PJSIP_AUTH_ALLOW_MULTIPLE_AUTH_HEADER")

View File

@ -1,306 +0,0 @@
From c4d34984ec92b3d5252a7d5cddd85a1d3a8001ae Mon Sep 17 00:00:00 2001
From: sauwming <ming@teluu.com>
Date: Mon, 3 Oct 2022 08:07:22 +0800
Subject: [PATCH] Merge pull request from GHSA-fq45-m3f7-3mhj
* Initial patch
* Use 'pj_scan_is_eof(scanner)'
Co-authored-by: Aaron Lichtman <aaronlichtman@gmail.com>
* Use 'pj_scan_is_eof(scanner)'
Co-authored-by: Aaron Lichtman <aaronlichtman@gmail.com>
* Use 'pj_scan_is_eof(scanner)'
Co-authored-by: Aaron Lichtman <aaronlichtman@gmail.com>
* Use `!pj_scan_is_eof` instead of manually checking `scanner->curptr < scanner->end`
Co-authored-by: Maksim Mukosey <mmukosey@gmail.com>
* Update pjlib-util/src/pjlib-util/scanner.c
Co-authored-by: Aaron Lichtman <aaronlichtman@gmail.com>
* Update pjlib-util/src/pjlib-util/scanner.c
Co-authored-by: Aaron Lichtman <aaronlichtman@gmail.com>
* Update pjlib-util/src/pjlib-util/scanner.c
Co-authored-by: Aaron Lichtman <aaronlichtman@gmail.com>
* Revert '>=' back to '>' in pj_scan_stricmp_alnum()
* Fix error compiles.
Co-authored-by: Nanang Izzuddin <nanang@teluu.com>
Co-authored-by: Aaron Lichtman <aaronlichtman@gmail.com>
Co-authored-by: Maksim Mukosey <mmukosey@gmail.com>
---
pjlib-util/src/pjlib-util/scanner.c | 41 +++++++++++++++++++----------
pjmedia/src/pjmedia/rtp.c | 11 +++++---
pjmedia/src/pjmedia/sdp.c | 24 ++++++++++-------
3 files changed, 48 insertions(+), 28 deletions(-)
diff --git a/pjlib-util/src/pjlib-util/scanner.c b/pjlib-util/src/pjlib-util/scanner.c
index a54edf2d8..6541bbae3 100644
--- a/pjlib-util/src/pjlib-util/scanner.c
+++ b/pjlib-util/src/pjlib-util/scanner.c
@@ -195,7 +195,13 @@ PJ_DEF(void) pj_scan_skip_whitespace( pj_scanner *scanner )
PJ_DEF(void) pj_scan_skip_line( pj_scanner *scanner )
{
- char *s = pj_memchr(scanner->curptr, '\n', scanner->end - scanner->curptr);
+ char *s;
+
+ if (pj_scan_is_eof(scanner)) {
+ return;
+ }
+
+ s = pj_memchr(scanner->curptr, '\n', scanner->end - scanner->curptr);
if (!s) {
scanner->curptr = scanner->end;
} else {
@@ -264,8 +270,7 @@ PJ_DEF(void) pj_scan_get( pj_scanner *scanner,
pj_assert(pj_cis_match(spec,0)==0);
- /* EOF is detected implicitly */
- if (!pj_cis_match(spec, *s)) {
+ if (pj_scan_is_eof(scanner) || !pj_cis_match(spec, *s)) {
pj_scan_syntax_err(scanner);
return;
}
@@ -299,8 +304,7 @@ PJ_DEF(void) pj_scan_get_unescape( pj_scanner *scanner,
/* Must not match character '%' */
pj_assert(pj_cis_match(spec,'%')==0);
- /* EOF is detected implicitly */
- if (!pj_cis_match(spec, *s) && *s != '%') {
+ if (pj_scan_is_eof(scanner) || !pj_cis_match(spec, *s) && *s != '%') {
pj_scan_syntax_err(scanner);
return;
}
@@ -436,7 +440,9 @@ PJ_DEF(void) pj_scan_get_n( pj_scanner *scanner,
scanner->curptr += N;
- if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) {
+ if (!pj_scan_is_eof(scanner) &&
+ PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws)
+ {
pj_scan_skip_whitespace(scanner);
}
}
@@ -467,15 +473,16 @@ PJ_DEF(int) pj_scan_get_char( pj_scanner *scanner )
PJ_DEF(void) pj_scan_get_newline( pj_scanner *scanner )
{
- if (!PJ_SCAN_IS_NEWLINE(*scanner->curptr)) {
+ if (pj_scan_is_eof(scanner) || !PJ_SCAN_IS_NEWLINE(*scanner->curptr)) {
pj_scan_syntax_err(scanner);
return;
}
+ /* We have checked scanner->curptr validity above */
if (*scanner->curptr == '\r') {
++scanner->curptr;
}
- if (*scanner->curptr == '\n') {
+ if (!pj_scan_is_eof(scanner) && *scanner->curptr == '\n') {
++scanner->curptr;
}
@@ -520,7 +527,9 @@ PJ_DEF(void) pj_scan_get_until( pj_scanner *scanner,
scanner->curptr = s;
- if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) {
+ if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
+ scanner->skip_ws)
+ {
pj_scan_skip_whitespace(scanner);
}
}
@@ -544,7 +553,9 @@ PJ_DEF(void) pj_scan_get_until_ch( pj_scanner *scanner,
scanner->curptr = s;
- if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) {
+ if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
+ scanner->skip_ws)
+ {
pj_scan_skip_whitespace(scanner);
}
}
@@ -570,7 +581,9 @@ PJ_DEF(void) pj_scan_get_until_chr( pj_scanner *scanner,
scanner->curptr = s;
- if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) {
+ if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
+ scanner->skip_ws)
+ {
pj_scan_skip_whitespace(scanner);
}
}
@@ -585,7 +598,9 @@ PJ_DEF(void) pj_scan_advance_n( pj_scanner *scanner,
scanner->curptr += N;
- if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && skip_ws) {
+ if (!pj_scan_is_eof(scanner) &&
+ PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && skip_ws)
+ {
pj_scan_skip_whitespace(scanner);
}
}
@@ -636,5 +651,3 @@ PJ_DEF(void) pj_scan_restore_state( pj_scanner *scanner,
scanner->line = state->line;
scanner->start_line = state->start_line;
}
-
-
diff --git a/pjmedia/src/pjmedia/rtp.c b/pjmedia/src/pjmedia/rtp.c
index 18917f18b..d29348cc5 100644
--- a/pjmedia/src/pjmedia/rtp.c
+++ b/pjmedia/src/pjmedia/rtp.c
@@ -188,6 +188,11 @@ PJ_DEF(pj_status_t) pjmedia_rtp_decode_rtp2(
/* Payload is located right after header plus CSRC */
offset = sizeof(pjmedia_rtp_hdr) + ((*hdr)->cc * sizeof(pj_uint32_t));
+ /* Check that offset is less than packet size */
+ if (offset >= pkt_len) {
+ return PJMEDIA_RTP_EINLEN;
+ }
+
/* Decode RTP extension. */
if ((*hdr)->x) {
if (offset + sizeof (pjmedia_rtp_ext_hdr) > (unsigned)pkt_len)
@@ -202,8 +207,8 @@ PJ_DEF(pj_status_t) pjmedia_rtp_decode_rtp2(
dec_hdr->ext_len = 0;
}
- /* Check that offset is less than packet size */
- if (offset > pkt_len)
+ /* Check again that offset is still less than packet size */
+ if (offset >= pkt_len)
return PJMEDIA_RTP_EINLEN;
/* Find and set payload. */
@@ -393,5 +398,3 @@ void pjmedia_rtp_seq_update( pjmedia_rtp_seq_session *sess,
seq_status->status.value = st.status.value;
}
}
-
-
diff --git a/pjmedia/src/pjmedia/sdp.c b/pjmedia/src/pjmedia/sdp.c
index 3905c2f52..647f49e13 100644
--- a/pjmedia/src/pjmedia/sdp.c
+++ b/pjmedia/src/pjmedia/sdp.c
@@ -983,13 +983,13 @@ static void parse_version(pj_scanner *scanner,
ctx->last_error = PJMEDIA_SDP_EINVER;
/* check equal sign */
- if (*(scanner->curptr+1) != '=') {
+ if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
on_scanner_error(scanner);
return;
}
/* check version is 0 */
- if (*(scanner->curptr+2) != '0') {
+ if (scanner->curptr+2 >= scanner->end || *(scanner->curptr+2) != '0') {
on_scanner_error(scanner);
return;
}
@@ -1006,7 +1006,7 @@ static void parse_origin(pj_scanner *scanner, pjmedia_sdp_session *ses,
ctx->last_error = PJMEDIA_SDP_EINORIGIN;
/* check equal sign */
- if (*(scanner->curptr+1) != '=') {
+ if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
on_scanner_error(scanner);
return;
}
@@ -1052,7 +1052,7 @@ static void parse_time(pj_scanner *scanner, pjmedia_sdp_session *ses,
ctx->last_error = PJMEDIA_SDP_EINTIME;
/* check equal sign */
- if (*(scanner->curptr+1) != '=') {
+ if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
on_scanner_error(scanner);
return;
}
@@ -1080,7 +1080,7 @@ static void parse_generic_line(pj_scanner *scanner, pj_str_t *str,
ctx->last_error = PJMEDIA_SDP_EINSDP;
/* check equal sign */
- if (*(scanner->curptr+1) != '=') {
+ if ((scanner->curptr+1 >= scanner->end) || *(scanner->curptr+1) != '=') {
on_scanner_error(scanner);
return;
}
@@ -1149,7 +1149,7 @@ static void parse_media(pj_scanner *scanner, pjmedia_sdp_media *med,
ctx->last_error = PJMEDIA_SDP_EINMEDIA;
/* check the equal sign */
- if (*(scanner->curptr+1) != '=') {
+ if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
on_scanner_error(scanner);
return;
}
@@ -1164,6 +1164,10 @@ static void parse_media(pj_scanner *scanner, pjmedia_sdp_media *med,
/* port */
pj_scan_get(scanner, &cs_token, &str);
med->desc.port = (unsigned short)pj_strtoul(&str);
+ if (pj_scan_is_eof(scanner)) {
+ on_scanner_error(scanner);
+ return;
+ }
if (*scanner->curptr == '/') {
/* port count */
pj_scan_get_char(scanner);
@@ -1175,7 +1179,7 @@ static void parse_media(pj_scanner *scanner, pjmedia_sdp_media *med,
}
if (pj_scan_get_char(scanner) != ' ') {
- PJ_THROW(SYNTAX_ERROR);
+ on_scanner_error(scanner);
}
/* transport */
@@ -1183,7 +1187,7 @@ static void parse_media(pj_scanner *scanner, pjmedia_sdp_media *med,
/* format list */
med->desc.fmt_count = 0;
- while (*scanner->curptr == ' ') {
+ while (scanner->curptr < scanner->end && *scanner->curptr == ' ') {
pj_str_t fmt;
pj_scan_get_char(scanner);
@@ -1223,7 +1227,7 @@ static pjmedia_sdp_attr *parse_attr( pj_pool_t *pool, pj_scanner *scanner,
attr = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_attr);
/* check equal sign */
- if (*(scanner->curptr+1) != '=') {
+ if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
on_scanner_error(scanner);
return NULL;
}
@@ -1242,7 +1246,7 @@ static pjmedia_sdp_attr *parse_attr( pj_pool_t *pool, pj_scanner *scanner,
pj_scan_get_char(scanner);
/* get value */
- if (*scanner->curptr != '\r' && *scanner->curptr != '\n') {
+ if (!pj_scan_is_eof(scanner) && *scanner->curptr != '\r' && *scanner->curptr != '\n') {
pj_scan_get_until_chr(scanner, "\r\n", &attr->value);
} else {
attr->value.ptr = NULL;
--
2.25.1

View File

@ -1,44 +0,0 @@
From 450baca94f475345542c6953832650c390889202 Mon Sep 17 00:00:00 2001
From: sauwming <ming@teluu.com>
Date: Tue, 7 Jun 2022 12:00:13 +0800
Subject: [PATCH] Merge pull request from GHSA-26j7-ww69-c4qj
---
pjlib-util/src/pjlib-util/stun_simple.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/pjlib-util/src/pjlib-util/stun_simple.c b/pjlib-util/src/pjlib-util/stun_simple.c
index 722519584..d0549176d 100644
--- a/pjlib-util/src/pjlib-util/stun_simple.c
+++ b/pjlib-util/src/pjlib-util/stun_simple.c
@@ -54,6 +54,7 @@ PJ_DEF(pj_status_t) pjstun_parse_msg( void *buf, pj_size_t buf_len,
{
pj_uint16_t msg_type, msg_len;
char *p_attr;
+ int attr_max_cnt = PJ_ARRAY_SIZE(msg->attr);
PJ_CHECK_STACK();
@@ -83,7 +84,7 @@ PJ_DEF(pj_status_t) pjstun_parse_msg( void *buf, pj_size_t buf_len,
msg->attr_count = 0;
p_attr = (char*)buf + sizeof(pjstun_msg_hdr);
- while (msg_len > 0) {
+ while (msg_len > 0 && msg->attr_count < attr_max_cnt) {
pjstun_attr_hdr **attr = &msg->attr[msg->attr_count];
pj_uint32_t len;
pj_uint16_t attr_type;
@@ -111,6 +112,10 @@ PJ_DEF(pj_status_t) pjstun_parse_msg( void *buf, pj_size_t buf_len,
p_attr += len;
++msg->attr_count;
}
+ if (msg->attr_count == attr_max_cnt) {
+ PJ_LOG(4, (THIS_FILE, "Warning: max number attribute %d reached.",
+ attr_max_cnt));
+ }
return PJ_SUCCESS;
}
--
2.25.1

View File

@ -1 +0,0 @@
7f80ba8e1540853f959be6be7912a150 pjproject-2.12.1.tar.bz2

View File

@ -0,0 +1 @@
221bc1d38106b879fdbcf6ca9389b80b pjproject-2.13.tar.bz2

View File

@ -1,2 +1,2 @@
JANSSON_VERSION = 2.14
PJPROJECT_VERSION = 2.12.1
PJPROJECT_VERSION = 2.13