Compare commits

...

12 Commits

Author SHA1 Message Date
Asterisk Development Team
987ad61270 Update for 16.6.1 2019-10-16 10:50:40 -05:00
Friendly Automation
574a7bfa97 Merge "res_pjsip_mwi: potential double unref, and potential unwanted double link" into 16.6 2019-10-14 12:54:29 -05:00
George Joseph
e6cc1f5083 pjproject_bundled: Replace earlier reverts with official fixes.
Issues in pjproject 2.9 caused us to revert some of their changes
as a work around.  This introduced another issue where pjproject
wouldn't build with older gcc versions such as that found on
CentOS 6.  This commit replaces the reverts with the official
fixes for the original issues and allows pjproject to be built
on CentOS 6 again.

ASTERISK-28574
Reported-by: Niklas Larsson

Change-Id: I06f8507bea553d1a01b0b8874197d35b9d47ec4c
(cherry picked from commit cb6e0d36ae)
2019-10-11 10:42:05 -05:00
Kevin Harwell
a92fdd25ac res_pjsip_mwi: potential double unref, and potential unwanted double link
When creating an unsolicited MWI aggregate subscription it was possible for
the subscription object to be double unref'ed. This patch removes the explicit
unref as it is not needed since the RAII_VAR will handle it at function end.

Less concerning there was also a bug that could potentially allow the aggregate
subscription object to be added to the unsolicited container twice. This patch
ensures it is added only once.

ASTERISK-28575

Change-Id: I9ccfdb5ea788bc0c3618db183aae235e53c12763
2019-10-10 15:30:52 -05:00
Asterisk Development Team
6a68c75ac7 Update for 16.6.0 2019-10-08 12:33:39 -05:00
Asterisk Development Team
e70a65eb55 Update for 16.6.0-rc2 2019-09-25 12:54:05 -05:00
Friendly Automation
1535da1b7d Merge "pjproject_bundled: Revert pjproject 2.9 commits causing leaks" into 16.6 2019-09-24 14:21:04 -05:00
George Joseph
2b75c4fc51 pjproject_bundled: Revert pjproject 2.9 commits causing leaks
We've found a connection re-use regression in pjproject 2.9
introduced by commit
"Close #1019: Support for multiple listeners."
https://trac.pjsip.org/repos/changeset/6002
https://trac.pjsip.org/repos/ticket/1019

Normally, multiple SSL requests should reuse the same connection
if one already exists to the remote server.  When a transport
error occurs, the next request should establish a new connection
and any following requests should use that same one.  With this
patch, when a transport error occurs, every new request creates
a new connection so you can wind up with thousands of open tcp
sockets, possibly exhausting file handles, and increasing memory
usage.

Reverting pjproject commit 6002 (and related 6021) restores the
expected behavior.

We also found a memory leak in SSL processing that was introduced by
commit
"Fixed #2204: Add OpenSSL remote certificate chain info"
https://trac.pjsip.org/repos/changeset/6014
https://trac.pjsip.org/repos/ticket/2204

Apparently the remote certificate chain is continually recreated
causing the leak.

Reverting pjproject commit 6014 (and related 6022) restores the
expected behavior.

Both of these issues have been acknowledged by Teluu.

ASTERISK-28521

Change-Id: I8ae7233c3ac4ec29a3b991f738e655dabcaba9f1
2019-09-24 08:26:04 -05:00
Kevin Harwell
6b072ab08c res_sorcery_memory_cache: stale item update leak
When a stale item was being updated the object was being retrieved, but its
reference was not being decremented after the update. This patch makes it so
the object is now appropriately de-referenced.

ASTERISK-28523

Change-Id: I9d8173d3a0416a242f4eba92fa0853279c500ec7
2019-09-23 11:30:04 -05:00
Joshua Colp
deb45228c8 chan_pjsip: Relock correct channel during "fax" redirect.
When fax detection occurs on an outbound PJSIP channel the
redirect operation will result in a masquerade occurring and
the underlying channel on the session changing. The code
incorrectly relocked the new channel instead of the old
channel when returning. This resulted in the new channel
being locked indefinitely. The code now always acts on the
expected channel.

ASTERISK-28538

Change-Id: I2b2e60d07e74383ae7e90d752c036c4b02d6b3a3
2019-09-17 15:36:28 -05:00
Guido Falsi
8931669b37 chan_dahdi: Fix build with clang/llvm
On FreeBSD using the clang/llvm compiler build fails to build due
to the switch statement argument being a non integer type expression.
Switch to an if/else if/else construct to sidestep the issue.

ASTERISK-28536 #close

Change-Id: Idf4a82cc1e94580a2d017fe9e351c226f23e20c8
2019-09-17 05:21:04 -05:00
Asterisk Development Team
951d914aab Update for 16.6.0-rc1 2019-09-12 16:08:20 -05:00
17 changed files with 88930 additions and 22 deletions

1
.lastclean Normal file
View File

@@ -0,0 +1 @@
40

1
.version Normal file
View File

@@ -0,0 +1 @@
16.6.1

85745
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><title>Release Summary - asterisk-16.6.1</title><h1 align="center"><a name="top">Release Summary</a></h1><h3 align="center">asterisk-16.6.1</h3><h3 align="center">Date: 2019-10-16</h3><h3 align="center">&lt;asteriskteam@digium.com&gt;</h3><hr><h2 align="center">Table of Contents</h2><ol>
<li><a href="#summary">Summary</a></li>
<li><a href="#contributors">Contributors</a></li>
<li><a href="#closed_issues">Closed Issues</a></li>
<li><a href="#diffstat">Diffstat</a></li>
</ol><hr><a name="summary"><h2 align="center">Summary</h2></a><center><a href="#top">[Back to Top]</a></center><p>This release is a point release of an existing major version. The changes included were made to address problems that have been identified in this release series, or are minor, backwards compatible new features or improvements. Users should be able to safely upgrade to this version if this release series is already in use. Users considering upgrading from a previous version are strongly encouraged to review the UPGRADE.txt document as well as the CHANGES document for information about upgrading to this release series.</p><p>The data in this summary reflects changes that have been made since the previous release, asterisk-16.6.0.</p><hr><a name="contributors"><h2 align="center">Contributors</h2></a><center><a href="#top">[Back to Top]</a></center><p>This table lists the people who have submitted code, those that have tested patches, as well as those that reported issues on the issue tracker that were resolved in this release. For coders, the number is how many of their patches (of any size) were committed into this release. For testers, the number is the number of times their name was listed as assisting with testing a patch. Finally, for reporters, the number is the number of issues that they reported that were affected by commits that went into this release.</p><table width="100%" border="0">
<tr><th width="33%">Coders</th><th width="33%">Testers</th><th width="33%">Reporters</th></tr>
<tr valign="top"><td width="33%">1 Kevin Harwell <kharwell@digium.com><br/>1 George Joseph <gjoseph@digium.com><br/></td><td width="33%"><td width="33%">1 Joshua Elson <joshelson@gmail.com><br/>1 Niklas Larsson<br/>1 Niklas Larsson <niklas@tese.se><br/></td></tr>
</table><hr><a name="closed_issues"><h2 align="center">Closed Issues</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a list of all issues from the issue tracker that were closed by changes that went into this release.</p><h3>Bug</h3><h4>Category: Resources/res_pjsip_mwi</h4><a href="https://issues.asterisk.org/jira/browse/ASTERISK-28575">ASTERISK-28575</a>: MWI Send Notify Crash on 16.6<br/>Reported by: Joshua Elson<ul>
<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=a92fdd25ac578ff2cee0c79c462c3ff3ec8da5c6">[a92fdd25ac]</a> Kevin Harwell -- res_pjsip_mwi: potential double unref, and potential unwanted double link</li>
</ul><br><h4>Category: pjproject/pjsip</h4><a href="https://issues.asterisk.org/jira/browse/ASTERISK-28574">ASTERISK-28574</a>: pjproject fails to build on 16.6.0, works on 16.5<br/>Reported by: Niklas Larsson<ul>
<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=e6cc1f5083bbb85a76280e4bbada7be265b0a106">[e6cc1f5083]</a> George Joseph -- pjproject_bundled: Replace earlier reverts with official fixes.</li>
</ul><br><hr><a name="diffstat"><h2 align="center">Diffstat Results</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a summary of the changes to the source code that went into this release that was generated using the diffstat utility.</p><pre>b/res/res_pjsip_mwi.c | 15
b/third-party/pjproject/patches/0030-ssl-regression-fix.patch | 105 +
b/third-party/pjproject/patches/0031-transport-regression-fix.patch | 187 +
third-party/pjproject/patches/0030-Revert-Misc-re-2147-Fixed-warnings-in-SSL-socket-red.patch | 60
third-party/pjproject/patches/0031-Revert-Fixed-2204-Add-OpenSSL-remote-certificate-cha.patch | 84
third-party/pjproject/patches/0032-Revert-Re-2147-misc-Fix-failed-pjsip-test-transport_.patch | 64
third-party/pjproject/patches/0033-Revert-Close-1019-Support-for-multiple-listeners.patch | 1006 ----------
7 files changed, 303 insertions(+), 1218 deletions(-)</pre><br></html>

View File

@@ -0,0 +1,97 @@
Release Summary
asterisk-16.6.1
Date: 2019-10-16
<asteriskteam@digium.com>
----------------------------------------------------------------------
Table of Contents
1. Summary
2. Contributors
3. Closed Issues
4. Diffstat
----------------------------------------------------------------------
Summary
[Back to Top]
This release is a point release of an existing major version. The changes
included were made to address problems that have been identified in this
release series, or are minor, backwards compatible new features or
improvements. Users should be able to safely upgrade to this version if
this release series is already in use. Users considering upgrading from a
previous version are strongly encouraged to review the UPGRADE.txt
document as well as the CHANGES document for information about upgrading
to this release series.
The data in this summary reflects changes that have been made since the
previous release, asterisk-16.6.0.
----------------------------------------------------------------------
Contributors
[Back to Top]
This table lists the people who have submitted code, those that have
tested patches, as well as those that reported issues on the issue tracker
that were resolved in this release. For coders, the number is how many of
their patches (of any size) were committed into this release. For testers,
the number is the number of times their name was listed as assisting with
testing a patch. Finally, for reporters, the number is the number of
issues that they reported that were affected by commits that went into
this release.
Coders Testers Reporters
1 Kevin Harwell 1 Joshua Elson
1 George Joseph 1 Niklas Larsson
1 Niklas Larsson
----------------------------------------------------------------------
Closed Issues
[Back to Top]
This is a list of all issues from the issue tracker that were closed by
changes that went into this release.
Bug
Category: Resources/res_pjsip_mwi
ASTERISK-28575: MWI Send Notify Crash on 16.6
Reported by: Joshua Elson
* [a92fdd25ac] Kevin Harwell -- res_pjsip_mwi: potential double unref,
and potential unwanted double link
Category: pjproject/pjsip
ASTERISK-28574: pjproject fails to build on 16.6.0, works on 16.5
Reported by: Niklas Larsson
* [e6cc1f5083] George Joseph -- pjproject_bundled: Replace earlier
reverts with official fixes.
----------------------------------------------------------------------
Diffstat Results
[Back to Top]
This is a summary of the changes to the source code that went into this
release that was generated using the diffstat utility.
b/res/res_pjsip_mwi.c | 15
b/third-party/pjproject/patches/0030-ssl-regression-fix.patch | 105 +
b/third-party/pjproject/patches/0031-transport-regression-fix.patch | 187 +
third-party/pjproject/patches/0030-Revert-Misc-re-2147-Fixed-warnings-in-SSL-socket-red.patch | 60
third-party/pjproject/patches/0031-Revert-Fixed-2204-Add-OpenSSL-remote-certificate-cha.patch | 84
third-party/pjproject/patches/0032-Revert-Re-2147-misc-Fix-failed-pjsip-test-transport_.patch | 64
third-party/pjproject/patches/0033-Revert-Close-1019-Support-for-multiple-listeners.patch | 1006 ----------
7 files changed, 303 insertions(+), 1218 deletions(-)

View File

@@ -15165,10 +15165,12 @@ static void mfcr2_show_links_of(struct ast_cli_args *a, struct r2links *list_hea
int channo;
int prev_channo;
x++;
switch (mfcr2->r2master) {
case 0L: thread_status = "zero"; break;
case AST_PTHREADT_NULL: thread_status = "none"; break;
default: thread_status = "created"; break;
if (mfcr2->r2master == 0L) {
thread_status = "zero";
} else if (mfcr2->r2master == AST_PTHREADT_NULL) {
thread_status = "none";
} else {
thread_status = "created";
}
snprintf(index, sizeof(index), "%d", mfcr2->index);
snprintf(live_chans_str, sizeof(live_chans_str), "%d", mfcr2->live_chans);

View File

@@ -749,7 +749,8 @@ static int chan_pjsip_answer(struct ast_channel *ast)
}
/*! \brief Internal helper function called when CNG tone is detected */
static struct ast_frame *chan_pjsip_cng_tone_detected(struct ast_sip_session *session, struct ast_frame *f)
static struct ast_frame *chan_pjsip_cng_tone_detected(struct ast_channel *ast, struct ast_sip_session *session,
struct ast_frame *f)
{
const char *target_context;
int exists;
@@ -765,11 +766,11 @@ static struct ast_frame *chan_pjsip_cng_tone_detected(struct ast_sip_session *se
}
/* If already executing in the fax extension don't do anything */
if (!strcmp(ast_channel_exten(session->channel), "fax")) {
if (!strcmp(ast_channel_exten(ast), "fax")) {
return f;
}
target_context = S_OR(ast_channel_macrocontext(session->channel), ast_channel_context(session->channel));
target_context = S_OR(ast_channel_macrocontext(ast), ast_channel_context(ast));
/*
* We need to unlock the channel here because ast_exists_extension has the
@@ -778,25 +779,30 @@ static struct ast_frame *chan_pjsip_cng_tone_detected(struct ast_sip_session *se
*
* ast_async_goto() has its own restriction on not holding the channel lock.
*/
ast_channel_unlock(session->channel);
ast_channel_unlock(ast);
ast_frfree(f);
f = &ast_null_frame;
exists = ast_exists_extension(session->channel, target_context, "fax", 1,
S_COR(ast_channel_caller(session->channel)->id.number.valid,
ast_channel_caller(session->channel)->id.number.str, NULL));
exists = ast_exists_extension(ast, target_context, "fax", 1,
S_COR(ast_channel_caller(ast)->id.number.valid,
ast_channel_caller(ast)->id.number.str, NULL));
if (exists) {
ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n",
ast_channel_name(session->channel));
pbx_builtin_setvar_helper(session->channel, "FAXEXTEN", ast_channel_exten(session->channel));
if (ast_async_goto(session->channel, target_context, "fax", 1)) {
ast_channel_name(ast));
pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast_channel_exten(ast));
if (ast_async_goto(ast, target_context, "fax", 1)) {
ast_log(LOG_ERROR, "Failed to async goto '%s' into fax extension in '%s'\n",
ast_channel_name(session->channel), target_context);
ast_channel_name(ast), target_context);
}
} else {
ast_log(LOG_NOTICE, "FAX CNG detected on '%s' but no fax extension in '%s'\n",
ast_channel_name(session->channel), target_context);
ast_channel_name(ast), target_context);
}
ast_channel_lock(session->channel);
/* It's possible for a masquerade to have occurred when doing the ast_async_goto resulting in
* the channel on the session having changed. Since we need to return with the original channel
* locked we lock the channel that was passed in and not session->channel.
*/
ast_channel_lock(ast);
return f;
}
@@ -895,7 +901,11 @@ static struct ast_frame *chan_pjsip_read_stream(struct ast_channel *ast)
if (f->subclass.integer == 'f') {
ast_debug(3, "Channel driver fax CNG detected on %s\n",
ast_channel_name(ast));
f = chan_pjsip_cng_tone_detected(session, f);
f = chan_pjsip_cng_tone_detected(ast, session, f);
/* When chan_pjsip_cng_tone_detected returns it is possible for the
* channel pointed to by ast and by session->channel to differ due to a
* masquerade. It's best not to touch things after this.
*/
} else {
ast_debug(3, "* Detected inband DTMF '%c' on '%s'\n", f->subclass.integer,
ast_channel_name(ast));

View File

@@ -0,0 +1,41 @@
CREATE TABLE alembic_version (
version_num VARCHAR(32) NOT NULL,
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num)
);
-- Running upgrade -> 210693f3123d
CREATE TABLE cdr (
accountcode VARCHAR(20),
src VARCHAR(80),
dst VARCHAR(80),
dcontext VARCHAR(80),
clid VARCHAR(80),
channel VARCHAR(80),
dstchannel VARCHAR(80),
lastapp VARCHAR(80),
lastdata VARCHAR(80),
start DATETIME,
answer DATETIME,
end DATETIME,
duration INTEGER,
billsec INTEGER,
disposition VARCHAR(45),
amaflags VARCHAR(45),
userfield VARCHAR(256),
uniqueid VARCHAR(150),
linkedid VARCHAR(150),
peeraccount VARCHAR(20),
sequence INTEGER
);
INSERT INTO alembic_version (version_num) VALUES ('210693f3123d');
-- Running upgrade 210693f3123d -> 54cde9847798
ALTER TABLE cdr MODIFY accountcode VARCHAR(80) NULL;
ALTER TABLE cdr MODIFY peeraccount VARCHAR(80) NULL;
UPDATE alembic_version SET version_num='54cde9847798' WHERE alembic_version.version_num = '210693f3123d';

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
CREATE TABLE alembic_version (
version_num VARCHAR(32) NOT NULL,
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num)
);
-- Running upgrade -> a2e9769475e
CREATE TABLE voicemail_messages (
dir VARCHAR(255) NOT NULL,
msgnum INTEGER NOT NULL,
context VARCHAR(80),
macrocontext VARCHAR(80),
callerid VARCHAR(80),
origtime INTEGER,
duration INTEGER,
recording BLOB,
flag VARCHAR(30),
category VARCHAR(30),
mailboxuser VARCHAR(30),
mailboxcontext VARCHAR(30),
msg_id VARCHAR(40)
);
ALTER TABLE voicemail_messages ADD CONSTRAINT voicemail_messages_dir_msgnum PRIMARY KEY (dir, msgnum);
CREATE INDEX voicemail_messages_dir ON voicemail_messages (dir);
INSERT INTO alembic_version (version_num) VALUES ('a2e9769475e');
-- Running upgrade a2e9769475e -> 39428242f7f5
ALTER TABLE voicemail_messages MODIFY recording BLOB(4294967295) NULL;
UPDATE alembic_version SET version_num='39428242f7f5' WHERE alembic_version.version_num = 'a2e9769475e';

View File

@@ -0,0 +1,45 @@
BEGIN;
CREATE TABLE alembic_version (
version_num VARCHAR(32) NOT NULL,
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num)
);
-- Running upgrade -> 210693f3123d
CREATE TABLE cdr (
accountcode VARCHAR(20),
src VARCHAR(80),
dst VARCHAR(80),
dcontext VARCHAR(80),
clid VARCHAR(80),
channel VARCHAR(80),
dstchannel VARCHAR(80),
lastapp VARCHAR(80),
lastdata VARCHAR(80),
start TIMESTAMP WITHOUT TIME ZONE,
answer TIMESTAMP WITHOUT TIME ZONE,
"end" TIMESTAMP WITHOUT TIME ZONE,
duration INTEGER,
billsec INTEGER,
disposition VARCHAR(45),
amaflags VARCHAR(45),
userfield VARCHAR(256),
uniqueid VARCHAR(150),
linkedid VARCHAR(150),
peeraccount VARCHAR(20),
sequence INTEGER
);
INSERT INTO alembic_version (version_num) VALUES ('210693f3123d');
-- Running upgrade 210693f3123d -> 54cde9847798
ALTER TABLE cdr ALTER COLUMN accountcode TYPE VARCHAR(80);
ALTER TABLE cdr ALTER COLUMN peeraccount TYPE VARCHAR(80);
UPDATE alembic_version SET version_num='54cde9847798' WHERE alembic_version.version_num = '210693f3123d';
COMMIT;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,39 @@
BEGIN;
CREATE TABLE alembic_version (
version_num VARCHAR(32) NOT NULL,
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num)
);
-- Running upgrade -> a2e9769475e
CREATE TABLE voicemail_messages (
dir VARCHAR(255) NOT NULL,
msgnum INTEGER NOT NULL,
context VARCHAR(80),
macrocontext VARCHAR(80),
callerid VARCHAR(80),
origtime INTEGER,
duration INTEGER,
recording BYTEA,
flag VARCHAR(30),
category VARCHAR(30),
mailboxuser VARCHAR(30),
mailboxcontext VARCHAR(30),
msg_id VARCHAR(40)
);
ALTER TABLE voicemail_messages ADD CONSTRAINT voicemail_messages_dir_msgnum PRIMARY KEY (dir, msgnum);
CREATE INDEX voicemail_messages_dir ON voicemail_messages (dir);
INSERT INTO alembic_version (version_num) VALUES ('a2e9769475e');
-- Running upgrade a2e9769475e -> 39428242f7f5
ALTER TABLE voicemail_messages ALTER COLUMN recording TYPE BYTEA;
UPDATE alembic_version SET version_num='39428242f7f5' WHERE alembic_version.version_num = 'a2e9769475e';
COMMIT;

View File

@@ -1289,6 +1289,13 @@ static int create_unsolicited_mwi_subscriptions(struct ast_sip_endpoint *endpoin
if (!aggregate_sub) {
return 0; /* No MWI aggregation for you */
}
/*
* Just in case we somehow get in the position of recreating with no previous
* aggregate object, set recreate to false here in order to allow the new
* object to be linked into the container below
*/
recreate = 0;
}
}
@@ -1330,13 +1337,13 @@ static int create_unsolicited_mwi_subscriptions(struct ast_sip_endpoint *endpoin
if (aggregate_sub) {
if (ao2_container_count(aggregate_sub->stasis_subs)) {
ao2_link_flags(unsolicited_mwi, aggregate_sub, OBJ_NOLOCK);
/* Only link if we're dealing with a new aggregate object */
if (!recreate) {
ao2_link_flags(unsolicited_mwi, aggregate_sub, OBJ_NOLOCK);
}
if (send_now && sub_added) {
send_notify(aggregate_sub, NULL, 0);
}
} else {
/* No stasis subscriptions then no MWI data to aggregate */
ao2_ref(aggregate_sub, -1);
}
}

View File

@@ -1006,6 +1006,7 @@ static int stale_item_update(const void *data)
ast_sorcery_object_get_id(task_data->object));
sorcery_memory_cache_create(task_data->sorcery, task_data->cache,
object);
ao2_ref(object, -1);
}
ast_test_suite_event_notify("SORCERY_MEMORY_CACHE_REFRESHED", "Cache: %s\r\nType: %s\r\nName: %s\r\n",

View File

@@ -0,0 +1,105 @@
From 489281f29fc7b97143cf79154f22e5007adaba39 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Wed, 9 Oct 2019 07:49:44 -0600
Subject: [PATCH 30/31] ssl regression fix
---
pjlib/src/pj/ssl_sock_gtls.c | 6 ++++--
pjlib/src/pj/ssl_sock_imp_common.c | 4 ++++
pjlib/src/pj/ssl_sock_imp_common.h | 3 +++
pjlib/src/pj/ssl_sock_ossl.c | 9 +++++----
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/pjlib/src/pj/ssl_sock_gtls.c b/pjlib/src/pj/ssl_sock_gtls.c
index 311b7b757..484770ae4 100644
--- a/pjlib/src/pj/ssl_sock_gtls.c
+++ b/pjlib/src/pj/ssl_sock_gtls.c
@@ -1050,7 +1050,8 @@ static void ssl_update_certs_info(pj_ssl_sock_t *ssock)
goto us_out;
tls_cert_get_info(ssock->pool, &ssock->local_cert_info, cert);
- tls_cert_get_chain_raw(ssock->pool, &ssock->local_cert_info, us, 1);
+ pj_pool_reset(ssock->info_pool);
+ tls_cert_get_chain_raw(ssock->info_pool, &ssock->local_cert_info, us, 1);
us_out:
tls_last_error = ret;
@@ -1077,7 +1078,8 @@ us_out:
goto peer_out;
tls_cert_get_info(ssock->pool, &ssock->remote_cert_info, cert);
- tls_cert_get_chain_raw(ssock->pool, &ssock->remote_cert_info, certs,
+ pj_pool_reset(ssock->info_pool);
+ tls_cert_get_chain_raw(ssock->info_pool, &ssock->remote_cert_info, certs,
certslen);
peer_out:
diff --git a/pjlib/src/pj/ssl_sock_imp_common.c b/pjlib/src/pj/ssl_sock_imp_common.c
index e6273d832..51a62a2fb 100644
--- a/pjlib/src/pj/ssl_sock_imp_common.c
+++ b/pjlib/src/pj/ssl_sock_imp_common.c
@@ -616,6 +616,7 @@ static void ssl_on_destroy(void *arg)
}
/* Secure release pool, i.e: all memory blocks will be zeroed first */
+ pj_pool_secure_release(&ssock->info_pool);
pj_pool_secure_release(&ssock->pool);
}
@@ -1262,15 +1263,18 @@ PJ_DEF(pj_status_t) pj_ssl_sock_create (pj_pool_t *pool,
{
pj_ssl_sock_t *ssock;
pj_status_t status;
+ pj_pool_t *info_pool;
PJ_ASSERT_RETURN(pool && param && p_ssock, PJ_EINVAL);
PJ_ASSERT_RETURN(param->sock_type == pj_SOCK_STREAM(), PJ_ENOTSUP);
+ info_pool = pj_pool_create(pool->factory, "ssl_chain%p", 512, 512, NULL);
pool = pj_pool_create(pool->factory, "ssl%p", 512, 512, NULL);
/* Create secure socket */
ssock = ssl_alloc(pool);
ssock->pool = pool;
+ ssock->info_pool = info_pool;
ssock->sock = PJ_INVALID_SOCKET;
ssock->ssl_state = SSL_STATE_NULL;
ssock->circ_buf_input.owner = ssock;
diff --git a/pjlib/src/pj/ssl_sock_imp_common.h b/pjlib/src/pj/ssl_sock_imp_common.h
index 09f259ef7..eb45f14e0 100644
--- a/pjlib/src/pj/ssl_sock_imp_common.h
+++ b/pjlib/src/pj/ssl_sock_imp_common.h
@@ -96,6 +96,9 @@ typedef struct circ_buf_t {
struct pj_ssl_sock_t
{
pj_pool_t *pool;
+ pj_pool_t *info_pool; /* this is for certificate chain
+ * information allocation. Don't use for
+ * other purposes. */
pj_ssl_sock_t *parent;
pj_ssl_sock_param param;
pj_ssl_sock_param newsock_param;
diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c
index b4ac5c15f..2545b7c37 100644
--- a/pjlib/src/pj/ssl_sock_ossl.c
+++ b/pjlib/src/pj/ssl_sock_ossl.c
@@ -1637,11 +1637,12 @@ static void ssl_update_certs_info(pj_ssl_sock_t *ssock)
chain = SSL_get_peer_cert_chain(ossock->ossl_ssl);
if (chain) {
- ssl_update_remote_cert_chain_info(ssock->pool,
- &ssock->remote_cert_info,
- chain, PJ_TRUE);
+ pj_pool_reset(ssock->info_pool);
+ ssl_update_remote_cert_chain_info(ssock->info_pool,
+ &ssock->remote_cert_info,
+ chain, PJ_TRUE);
} else {
- ssock->remote_cert_info.raw_chain.cnt = 0;
+ ssock->remote_cert_info.raw_chain.cnt = 0;
}
}
--
2.21.0

View File

@@ -0,0 +1,187 @@
From 9c6108ca392d5e0392e7fb5d2ffde85e3c44ce55 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Wed, 9 Oct 2019 07:50:32 -0600
Subject: [PATCH 31/31] transport regression fix
---
pjsip/src/pjsip/sip_transport.c | 73 +++++++++++++++++++++++++++------
1 file changed, 61 insertions(+), 12 deletions(-)
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index 65ac823d4..da6b70e50 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -50,6 +50,24 @@ static const char *addr_string(const pj_sockaddr_t *addr)
str, sizeof(str));
return str;
}
+static const char* print_tpsel_info(const pjsip_tpselector *sel)
+{
+ static char tpsel_info_buf[80];
+ if (!sel) return "(null)";
+ if (sel->type==PJSIP_TPSELECTOR_LISTENER)
+ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),
+ "listener[%s], reuse=%d", sel->u.listener->obj_name,
+ !sel->disable_connection_reuse);
+ else if (sel->type==PJSIP_TPSELECTOR_TRANSPORT)
+ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),
+ "transport[%s], reuse=%d", sel->u.transport->info,
+ !sel->disable_connection_reuse);
+ else
+ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),
+ "unknown[%p], reuse=%d", sel->u.ptr,
+ !sel->disable_connection_reuse);
+ return tpsel_info_buf;
+}
#else
# define TRACE_(x)
#endif
@@ -1210,10 +1228,14 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,
* new transport to the list.
*/
pj_list_push_back(tp_ref, tp_add);
+ TRACE_((THIS_FILE, "Remote address already registered, "
+ "appended the transport to the list"));
} else {
/* Transport list not found, add it to the hash table. */
pj_hash_set_np(mgr->table, &tp->key, key_len, hval, tp_add->tp_buf,
tp_add);
+ TRACE_((THIS_FILE, "Remote address not registered, "
+ "added the transport to the hash"));
}
/* Add ref transport group lock, if any */
@@ -1283,6 +1305,13 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,
/* The transport list has multiple entry. */
pj_hash_set_np(mgr->table, &tp_next->tp->key, key_len,
hval, tp_next->tp_buf, tp_next);
+ TRACE_((THIS_FILE, "Hash entry updated after "
+ "transport %d being destroyed",
+ tp->obj_name));
+ } else {
+ TRACE_((THIS_FILE, "Hash entry deleted after "
+ "transport %d being destroyed",
+ tp->obj_name));
}
}
@@ -1294,6 +1323,14 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,
}
tp_iter = tp_iter->next;
} while (tp_iter != tp_ref);
+
+ if (tp_iter->tp != tp) {
+ PJ_LOG(3, (THIS_FILE, "Warning: transport %s being destroyed is "
+ "not registered", tp->obj_name));
+ }
+ } else {
+ PJ_LOG(3, (THIS_FILE, "Warning: transport %s being destroyed is "
+ "not found in the hash table", tp->obj_name));
}
pj_lock_release(mgr->lock);
@@ -2159,6 +2196,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport(pjsip_tpmgr *mgr,
NULL, tp);
}
+
/*
* pjsip_tpmgr_acquire_transport2()
*
@@ -2176,8 +2214,9 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
pjsip_tpfactory *factory;
pj_status_t status;
- TRACE_((THIS_FILE,"Acquiring transport type=%s, remote=%s:%d",
+ TRACE_((THIS_FILE,"Acquiring transport type=%s, sel=%s remote=%s:%d",
pjsip_transport_get_type_name(type),
+ print_tpsel_info(sel),
addr_string(remote),
pj_sockaddr_get_port(remote)));
@@ -2194,6 +2233,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
/* See if the transport is (not) suitable */
if (seltp->key.type != type) {
pj_lock_release(mgr->lock);
+ TRACE_((THIS_FILE, "Transport type in tpsel not matched"));
return PJSIP_ETPNOTSUITABLE;
}
@@ -2234,6 +2274,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
{
if (sel->u.listener->type != type) {
pj_lock_release(mgr->lock);
+ TRACE_((THIS_FILE, "Listener type in tpsel not matched"));
return PJSIP_ETPNOTSUITABLE;
}
}
@@ -2249,21 +2290,25 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
tp_entry = (transport *)pj_hash_get(mgr->table, &key, key_len,
NULL);
if (tp_entry) {
- if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER) {
- transport *tp_iter = tp_entry;
- do {
+ transport *tp_iter = tp_entry;
+ do {
+ /* Don't use transport being shutdown */
+ if (!tp_iter->tp->is_shutdown) {
if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&
- sel->u.listener &&
- tp_iter->tp->factory == sel->u.listener)
+ sel->u.listener)
{
+ /* Match listener if selector is set */
+ if (tp_iter->tp->factory == sel->u.listener) {
+ tp_ref = tp_iter->tp;
+ break;
+ }
+ } else {
tp_ref = tp_iter->tp;
break;
}
- tp_iter = tp_iter->next;
- } while (tp_iter != tp_entry);
- } else {
- tp_ref = tp_entry->tp;
- }
+ }
+ tp_iter = tp_iter->next;
+ } while (tp_iter != tp_entry);
}
}
@@ -2276,7 +2321,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
/* Ignore address for loop transports. */
if (type == PJSIP_TRANSPORT_LOOP ||
- type == PJSIP_TRANSPORT_LOOP_DGRAM)
+ type == PJSIP_TRANSPORT_LOOP_DGRAM)
{
pj_sockaddr *addr = &key.rem_addr;
@@ -2315,6 +2360,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
* 'duplicate' of the existing transport (same type & remote addr,
* but different factory).
*/
+ TRACE_((THIS_FILE, "Transport found but from different listener"));
}
if (tp_ref!=NULL && !tp_ref->is_shutdown) {
@@ -2347,10 +2393,13 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
*/
/* Verify that the listener type matches the destination type */
+ /* Already checked above. */
+ /*
if (sel->u.listener->type != type) {
pj_lock_release(mgr->lock);
return PJSIP_ETPNOTSUITABLE;
}
+ */
/* We'll use this listener to create transport */
factory = sel->u.listener;
--
2.21.0