asterisk/asterisk.git
14 months agoResolve warning about duplicate 'dialplan' CLI.
Corey Farrell [Thu, 13 Sep 2018 18:03:15 +0000 (14:03 -0400)]
Resolve warning about duplicate 'dialplan' CLI.

Change-Id: I029db1b4a32ccfb38374d6fe944dc430866f4b30

14 months agoloader: Fix result of module reload error.
Corey Farrell [Tue, 2 Oct 2018 06:33:44 +0000 (02:33 -0400)]
loader: Fix result of module reload error.

When a module reload fails we never set AST_MODULE_RELOAD_ERROR.  This
caused reload failures to incorrectly report 'No module found'.

Change-Id: I5f3953e0f7d135e53ec797f24c97ee3f73f232e7

14 months agoloader: Improve error handling.
Corey Farrell [Fri, 28 Sep 2018 15:13:39 +0000 (11:13 -0400)]
loader: Improve error handling.

* Display list of unavailable dependencies when they cause another
  module to fail loading.
* When a module declines to load find all modules which depend on it so
  they can be declined and listed together.
* Prevent retry of declined modules during startup.
* When a module fails to dlopen try loading it with RTLD_LAZY so we can
  attempt to display the list of missing dependencies.

These changes are meant to reduce logger spam that is caused when a
module has many dependencies and declines to load.  This also fixes some
error paths which failed to recognize required modules.

Module load/start errors are delayed until the end of loader startup.

Change-Id: I046052c71331c556c09d39f47a3b92975f3e1758

14 months agocore/frame: Fix ast_frdup() and ast_frisolate() for empty text frames
neutrino88 [Tue, 25 Sep 2018 21:19:36 +0000 (17:19 -0400)]
core/frame: Fix ast_frdup() and ast_frisolate() for empty text frames

If a channel creates an AST_TEXT_FRAME with datalen == 0, the ast_frdup()
and ast_frisolate() functions could create a clone frame with an invalid
data.ptr which would cause a crash.  The proposed fix is to make sure that
for such empty text frames, ast_frdup() and ast_frisolate() return cloned
text frames with a valid data.ptr.

ASTERISK-28076
Reported by: Emmanuel BUU
Tested by: Emmanuel BUU

Change-Id: Ib882dd028598f13c4c233edbfdd7e54ad44a68e9

14 months agoMerge "Append CHANGES/UPGRADE.txt for module loader changes."
Joshua Colp [Tue, 2 Oct 2018 13:47:48 +0000 (08:47 -0500)]
Merge "Append CHANGES/UPGRADE.txt for module loader changes."

14 months agoMerge "app_queue.c: Fix json ref leak"
Joshua Colp [Tue, 2 Oct 2018 12:58:26 +0000 (07:58 -0500)]
Merge "app_queue.c: Fix json ref leak"

14 months agoastobj2: Record lock usage to refs log when DEBUG_THREADS is enabled.
Corey Farrell [Mon, 1 Oct 2018 04:11:44 +0000 (00:11 -0400)]
astobj2: Record lock usage to refs log when DEBUG_THREADS is enabled.

When DEBUG_THREADS is enabled we can know if the astobj2 mutex / rwlock
was ever used, so it can be recorded in the REF_DEBUG destructor entry.

Create contrib/scripts/reflocks.py to process locking used by
allocator.  This can be used to identify places where
AO2_ALLOC_OPT_LOCK_NOLOCK should be used to reduce memory usage.

Change-Id: I2e3cd23336a97df2692b545f548fd79b14b53bf4

14 months agoMerge "app_page: Add dependency against app_confbridge."
George Joseph [Mon, 1 Oct 2018 19:19:48 +0000 (14:19 -0500)]
Merge "app_page: Add dependency against app_confbridge."

14 months agoapp_page: Add dependency against app_confbridge.
Corey Farrell [Mon, 1 Oct 2018 17:11:41 +0000 (13:11 -0400)]
app_page: Add dependency against app_confbridge.

Change-Id: I1946509f518961d23fb21229d91676ee3e441921

14 months agoapp_queue.c: Fix json ref leak
Richard Mudgett [Fri, 28 Sep 2018 18:55:43 +0000 (13:55 -0500)]
app_queue.c: Fix json ref leak

Declining the queue_member_status_type stasis message in stasis.conf
causes these messages to leak json objects.

* Add missing ast_json_unref() if the type is NULL in
queue_publish_member_blob().

ASTERISK-28084

Change-Id: I691ecf49bd1f7d9c29182e1eee8c4bb7103be9fc

14 months agoMerge "astobj2: Reduce memory overhead."
Jenkins2 [Mon, 1 Oct 2018 14:02:37 +0000 (09:02 -0500)]
Merge "astobj2: Reduce memory overhead."

14 months agoMerge "lock: Improve performance of DEBUG_THREADS."
Joshua Colp [Mon, 1 Oct 2018 13:32:49 +0000 (08:32 -0500)]
Merge "lock: Improve performance of DEBUG_THREADS."

14 months agoMerge "configure.ac: Check for unbound version >= 1.5"
Joshua Colp [Mon, 1 Oct 2018 12:08:52 +0000 (07:08 -0500)]
Merge "configure.ac:  Check for unbound version >= 1.5"

14 months agoMerge "res_pjsip: improve realtime performance on CLI 'pjsip show contacts'"
Joshua Colp [Mon, 1 Oct 2018 11:51:37 +0000 (06:51 -0500)]
Merge "res_pjsip: improve realtime performance on CLI 'pjsip show contacts'"

14 months agoMerge "jansson-bundled: Add patches to improve json_pack error reporting."
Joshua Colp [Mon, 1 Oct 2018 11:24:46 +0000 (06:24 -0500)]
Merge "jansson-bundled: Add patches to improve json_pack error reporting."

14 months agoMerge "app_confbridge: Use bridge join hook to send join and leave events"
Joshua Colp [Mon, 1 Oct 2018 11:24:21 +0000 (06:24 -0500)]
Merge "app_confbridge:  Use bridge join hook to send join and leave events"

14 months agoMerge "res_stasis: Fix stale data in ARI bridges"
Joshua Colp [Mon, 1 Oct 2018 09:34:30 +0000 (04:34 -0500)]
Merge "res_stasis: Fix stale data in ARI bridges"

14 months agoAppend CHANGES/UPGRADE.txt for module loader changes.
Corey Farrell [Mon, 1 Oct 2018 08:24:00 +0000 (04:24 -0400)]
Append CHANGES/UPGRADE.txt for module loader changes.

Change-Id: Ib8db4e14187f5c11ecbff532df17d30c5d36fa3e

14 months agores_pjsip: improve realtime performance on CLI 'pjsip show contacts'
Alexei Gradinari [Tue, 25 Sep 2018 22:33:32 +0000 (18:33 -0400)]
res_pjsip: improve realtime performance on CLI 'pjsip show contacts'

CLI command 'pjsip show contacts' inefficiently make a lot of DB requests.

For example if there are 10k aors then asterisk requests these 10k records
of aor and then does 10k requests of contact - one request per aor.

Even if use 'like <pattern>' the asterisk requests all aor's and contact's
records and then filters them by itself.

This patch gathers contact's container by
- retrieving all dynamic contacts by regex (filtered by reg_server)
- retrieving all aors with permanent contacts
- finally filters container by regex

ASTERISK-28077 #close

Change-Id: Id0ad65d14952a02fb213273a90f3f680a8149618

14 months agojansson-bundled: Add patches to improve json_pack error reporting.
Corey Farrell [Fri, 28 Sep 2018 19:45:36 +0000 (15:45 -0400)]
jansson-bundled: Add patches to improve json_pack error reporting.

Change-Id: I045e420d5e73e60639079246e810da6ae21ae22b

14 months agolock: Improve performance of DEBUG_THREADS.
Corey Farrell [Fri, 28 Sep 2018 00:32:21 +0000 (20:32 -0400)]
lock: Improve performance of DEBUG_THREADS.

Add a volatile flag to lock tracking structures so we only need to use
the global lock when first initializing tracking.

Additionally add support for DEBUG_THREADS_LOOSE_ABI.  This is used by
astobj2.c to eliminate storage for tracking fields when DEBUG_THREADS is
not defined.

Change-Id: Iabd650908901843e9fff47ef1c539f0e1b8cb13b

14 months agoMerge "config.c: Cleanup AST_INCLUDE_GLOB"
George Joseph [Fri, 28 Sep 2018 18:16:17 +0000 (13:16 -0500)]
Merge "config.c: Cleanup AST_INCLUDE_GLOB"

14 months agoMerge "res_odbc: fix missing SQL error diagnostic"
Kevin Harwell [Fri, 28 Sep 2018 15:39:21 +0000 (10:39 -0500)]
Merge "res_odbc: fix missing SQL error diagnostic"

14 months agoMerge "astobj2: Fix shutdown order."
George Joseph [Fri, 28 Sep 2018 13:38:30 +0000 (08:38 -0500)]
Merge "astobj2: Fix shutdown order."

14 months agoMerge "app_queue: Fix Attended transfer hangup with removing pending member."
George Joseph [Fri, 28 Sep 2018 12:49:16 +0000 (07:49 -0500)]
Merge "app_queue: Fix Attended transfer hangup with removing pending member."

14 months agoapp_confbridge: Use bridge join hook to send join and leave events
George Joseph [Thu, 27 Sep 2018 18:19:28 +0000 (12:19 -0600)]
app_confbridge:  Use bridge join hook to send join and leave events

The first attempt at publishing confbridge events to participants
involved publishing them at the same time stasis events were
created.  This caused issues with bridge and channel locks.  The
second attempt involved publishing them when the stasis events
were received by the code that published the confbridge AMI events.
This caused timing issues because, depending on resources available,
the event could be received before channels actually joined the
bridge and would therefore fail to send messages to the participant.

This attempt reverts to the original mechanism with one exception.
The join and leave events are published via bridge join and leave
hooks.  This guarantees the states of the channels and bridge and
provides deterministic timing for event publishing.

Change-Id: I2660074f8a30a5224cb953d5e047ee84484a9036

14 months agoMerge "res_rtp_asterisk.c: Add "seqno" strictrtp option"
George Joseph [Fri, 28 Sep 2018 12:27:24 +0000 (07:27 -0500)]
Merge "res_rtp_asterisk.c: Add "seqno" strictrtp option"

14 months agoastobj2: Reduce memory overhead.
Corey Farrell [Thu, 27 Sep 2018 09:51:43 +0000 (05:51 -0400)]
astobj2: Reduce memory overhead.

Reduce options to 2-bit field, magic to 30 bit field.  Move ref_counter
next to options and explicitly use int32_t so the fields will pack.

This reduces memory overhead for every ao2 object by 8 bytes on x86_64.

Change-Id: Idc1baabb35ec3b3d8de463c4fa3011eaf7fcafb5

14 months agoconfig.c: Cleanup AST_INCLUDE_GLOB
Sean Bright [Thu, 27 Sep 2018 20:01:58 +0000 (16:01 -0400)]
config.c: Cleanup AST_INCLUDE_GLOB

* In main/config.c, AST_INCLUDE_GLOB is fixed to '1' making the #ifdefs
  pointless.

* In utils/extconf.c, AST_INCLUDE_GLOB is never defined so there is a
  lot of dead code.

Change-Id: I1bad1a46d7466ddf90d52cc724e997195495226c

14 months agoMerge "res_rtp_asterisk: Raise event when RTP port is allocated"
George Joseph [Thu, 27 Sep 2018 14:20:24 +0000 (09:20 -0500)]
Merge "res_rtp_asterisk: Raise event when RTP port is allocated"

14 months agoMerge "CI: Add --test-timeout option to runTestsuite.sh"
Joshua Colp [Thu, 27 Sep 2018 11:22:40 +0000 (06:22 -0500)]
Merge "CI:  Add --test-timeout option to runTestsuite.sh"

14 months agoastobj2: Fix shutdown order.
Corey Farrell [Thu, 27 Sep 2018 10:33:22 +0000 (06:33 -0400)]
astobj2: Fix shutdown order.

When REF_DEBUG and AO2_DEBUG are both enabled we closed the refs log
before we shutdown astobj2_container.  This caused the AO2_DEBUG
container registration container to be reported as a leak.

Change-Id: If9111c4c21c68064b22c546d5d7a41fac430430e

14 months agoapp_queue: Fix Attended transfer hangup with removing pending member.
Cao Minh Hiep [Thu, 6 Sep 2018 02:14:12 +0000 (11:14 +0900)]
app_queue: Fix Attended transfer hangup with removing pending member.

This issue related to setting of holdtime, announcements, member delays.
It works well if we set the member delays to "0" and no announcements
and no holdtime.This issue will happen if we set member delays to "1",
"2"... or announcements or holdtime and hangs up the call during
processing it.

And here is the reason:
(At the step of answering a phone.)
It takes care any holdtime, announcements, member delays,
or other options after a call has been answered if it exists.

Normally, After the call has been aswered,
and we wait for the processing one of the cases of the member delays
or hold time or announcements finished, "if (ast_check_hangup(peer))"
will be not executed, then queue will be updated at update_queue().
Here, pending member will be removed.

However, after the call has been aswered,
if we hangs up the call during one of the cases of the member delays
or hold time or announcements, "if (ast_check_hangup(peer))"
will be executed.
outgoing = NULL and at hangupcalls, pending members will not be removed.

* This fixed patch will remove the pending member from container
before hanging up the call with outgoing is NULL.

ASTERISK-27920

Reported by: Cao Minh Hiep
Tested by: Cao Minh Hiep

Change-Id: Ib780fbf48ace9d2d8eaa1270b9d530a4fc14c855

14 months agores_stasis: Fix stale data in ARI bridges
Moritz Fain [Tue, 26 Jun 2018 14:17:37 +0000 (16:17 +0200)]
res_stasis: Fix stale data in ARI bridges

Fixed an issue that resulted in "Allocation failed" each time an ARI
request was made to start playing MOH on a bridge.

In bridge_moh_create() we were attaching the after bridge callbacks to
chan which is the ;1 channel of the unreal channel pair.  We should have
attached them to the ;2 channel which is pushed into the bridge by
ast_unreal_channel_push_to_bridge().  The callbacks are called when the
specific channel leaves the bridging system.  Since the ;1 channel is
never put into a bridge the callbacks never get called.  The callbacks
then never remove the moh_wrapper from the app_bridges_moh container.  As
a result we cannot find the channel associated with the wrapper to start
MOH because it has hungup.  This is the reason causing the reported issue.

* Rather than using after bridge callbacks to cleanup, we now have
moh_channel_thread() doing the cleanup when the channel hangs up.

* Fixed moh_channel_thread() accumulating control frames on the stasis
bridge MOH channel until MOH is stopped.  Control frames are no longer
accumulated while MOH is playing.

* Fixed channel ref counting issue.  stasis_app_bridge_moh_channel() may
or may not return a channel ref.  As a result ast_ari_bridges_start_moh()
wouldn't know it may have a channel ref to release.
stasis_app_bridge_moh_channel() will now return a ref with the channel it
returns.

* Eliminated RAII_VAR in bridge_moh_create().

ASTERISK-26094 #close

Change-Id: Ibff479e167b3320c68aaabfada7e1d0ef7bd548c

14 months agores_rtp_asterisk.c: Add "seqno" strictrtp option
Ben Ford [Mon, 10 Sep 2018 16:28:09 +0000 (11:28 -0500)]
res_rtp_asterisk.c: Add "seqno" strictrtp option

When networks experience disruptions, there can be large gaps of time
between receiving packets. When strictrtp is enabled, this created
issues where a flood of packets could come in and be seen as an attack.
Another option - seqno - has been added to the strictrtp option that
ignores the time interval and goes strictly by sequence number for
validity.

Change-Id: I8a42b8d193673899c8fc22fe7f98ea87df89be71

14 months agoMerge "jansson: Backport fixes to bundled, use json_vsprintf if available."
George Joseph [Wed, 26 Sep 2018 16:09:50 +0000 (11:09 -0500)]
Merge "jansson: Backport fixes to bundled, use json_vsprintf if available."

14 months agoMerge "chan_sip: SipNotify on Chan_Sip vi AMI behave different to CLI"
George Joseph [Wed, 26 Sep 2018 14:34:10 +0000 (09:34 -0500)]
Merge "chan_sip: SipNotify on Chan_Sip vi AMI behave different to CLI"

14 months agores_odbc: fix missing SQL error diagnostic
Alexei Gradinari [Thu, 20 Sep 2018 18:59:54 +0000 (14:59 -0400)]
res_odbc: fix missing SQL error diagnostic

On SQL error there is not diagnostic information about this error.
There is only
WARNING res_odbc.c: SQL Execute error -1!

The function ast_odbc_print_errors calls a SQLGetDiagField to get the number
of available diagnostic records, but the SQLGetDiagField returns 0.
However SQLGetDiagRec could return one diagnostic records in this case.

Looking at many example of getting diagnostics error information
I found out that the best way it's to use only SQLGetDiagRec
while it returns SQL_SUCCESS.

Also this patch adds calls of ast_odbc_print_errors on SQL_ERROR
to res_config_odbc.

ASTERISK-28065 #close

Change-Id: Iba5ae5470ac49ecd911dd084effbe9efac68ccc1

14 months agoCI: Add --test-timeout option to runTestsuite.sh
George Joseph [Wed, 26 Sep 2018 13:12:28 +0000 (07:12 -0600)]
CI:  Add --test-timeout option to runTestsuite.sh

The default is 600 seconds.
Also added timeouts to the *TestGroups.json files.

Change-Id: I8ab6a69e704b6a10f06a0e52ede02312a2b72fe0

14 months agoMerge "rtp_engine: rtcp_report_to_json can overflow the ssrc integer value"
George Joseph [Wed, 26 Sep 2018 13:02:28 +0000 (08:02 -0500)]
Merge "rtp_engine: rtcp_report_to_json can overflow the ssrc integer value"

14 months agochan_sip: SipNotify on Chan_Sip vi AMI behave different to CLI
pk16208 [Tue, 18 Sep 2018 13:01:02 +0000 (15:01 +0200)]
chan_sip: SipNotify on Chan_Sip vi AMI behave different to CLI

With tls and udp enabled asterisk generates a warning about sending
message via udp instead of tls.
sip notify command via cli works as expected and without warning.

asterisk has to set the connection information accordingly to connection
and not on presumption

ASTERISK-28057 #close

Change-Id: Ib43315aba1f2c14ba077b52d8c5b00be0006656e

14 months agoconfigure.ac: Check for unbound version >= 1.5
George Joseph [Mon, 24 Sep 2018 22:56:07 +0000 (16:56 -0600)]
configure.ac:  Check for unbound version >= 1.5

In order to do this and provide good feedback, a new macro was
created (AST_EXT_LIB_EXTRA_CHECK) which does the normal check and
path setups for the library then compiles, links and runs a supplied
code fragment to do the final determination.  In this case, the
final code fragment compares UNBOUND_VERSION_MAJOR
and UNBOUND_VERSION_MINOR to determine if they're greater than or
equal to 1.5.

Since we require version 1.5, some code in res_resolver_unbound
was also simplified.

ASTERISK-28045
Reported by: Samuel Galarneau

Change-Id: Iee94ad543cd6f8b118df8c4c7afd9c4e2ca1fa72

14 months agores_rtp_asterisk: Raise event when RTP port is allocated
Joshua Colp [Mon, 24 Sep 2018 17:43:17 +0000 (17:43 +0000)]
res_rtp_asterisk: Raise event when RTP port is allocated

This change raises a testsuite event to provide what port
Asterisk has actually allocated for RTP. This ensures that
testsuite tests can remove any assumption of ports and instead
use the actual port in use.

ASTERISK-28070

Change-Id: I91bd45782e84284e01c89acf4b2da352e14ae044

14 months agojansson: Backport fixes to bundled, use json_vsprintf if available.
Corey Farrell [Tue, 17 Jul 2018 03:55:02 +0000 (23:55 -0400)]
jansson: Backport fixes to bundled, use json_vsprintf if available.

Use json_vsprintf from versions which contain fix for va_copy leak.

Apply fixes from jansson master:
* va_copy leak fix.
* Avoid potential invalid memory read in json_pack.
* Rename variable that shadowed another.

Change-Id: I7522e462d2a52f53010ffa1e7d705c666ec35539

14 months agojson: Take advantage of new API's.
Corey Farrell [Tue, 17 Jul 2018 03:55:02 +0000 (23:55 -0400)]
json: Take advantage of new API's.

* Use "o*" format specifier for optional fields in ast_json_party_id.
* Stop using ast_json_deep_copy on immutable objects, it is now thread
  safe to just use ast_json_ref.

Additional changes to ast_json_pack calls in the vicinity:
* Use "O" when an object needs to be bumped.  This was previously
  avoided as it was not thread safe.
* Use "o?" and "O?" to replace NULL with ast_json_null().  The
  "?" is a new feature of ast_json_pack starting with Asterisk 16.

Change-Id: I8382d28d7d83ee0ce13334e51ae45dbc0bdaef48

14 months agoMerge "app_voicemail: Fix stack overrun in append_mailbox"
George Joseph [Mon, 24 Sep 2018 18:50:36 +0000 (13:50 -0500)]
Merge "app_voicemail:  Fix stack overrun in append_mailbox"

14 months agoMerge "app_voicemail: Cleanup mailbox topic and cache"
George Joseph [Mon, 24 Sep 2018 16:46:50 +0000 (11:46 -0500)]
Merge "app_voicemail:  Cleanup mailbox topic and cache"

14 months agoMerge "chan_sip.c: chan_sip unstable with TLS after asterisk start or reloads"
George Joseph [Mon, 24 Sep 2018 15:44:51 +0000 (10:44 -0500)]
Merge "chan_sip.c: chan_sip unstable with TLS after asterisk start or reloads"

14 months agoMerge "res_remb_modifier: Add module for controlling REMB from CLI."
George Joseph [Mon, 24 Sep 2018 15:11:54 +0000 (10:11 -0500)]
Merge "res_remb_modifier: Add module for controlling REMB from CLI."

14 months agoapp_voicemail: Cleanup mailbox topic and cache
George Joseph [Thu, 20 Sep 2018 15:15:48 +0000 (09:15 -0600)]
app_voicemail:  Cleanup mailbox topic and cache

app_voicemail wasn't properly cleaning up the stasis cache or the
mwi topic pool when the module was unloaded or when a user was
deleted as a result of a reload.  This resulted in leaks in both
areas.

* app_voicemail now calls ast_delete_mwi_state_full when it frees
  a user structure and ast_delete_mwi_state_full in turn now calls
  the new stasis_topic_pool_delete_topic function to clear the topic
  from the pool.

Change-Id: Ide23144a4a810e7e0faad5a8e988d15947965df8

14 months agoMerge "stasis: Add function to delete topic from pool"
George Joseph [Mon, 24 Sep 2018 14:29:14 +0000 (09:29 -0500)]
Merge "stasis:  Add function to delete topic from pool"

14 months agoMerge "res_rtp_asterisk: Fix crash on ast_rtp_new failure."
George Joseph [Mon, 24 Sep 2018 14:27:01 +0000 (09:27 -0500)]
Merge "res_rtp_asterisk: Fix crash on ast_rtp_new failure."

14 months agoMerge "channel.c: Address stack overflow in does_id_conflict()"
George Joseph [Mon, 24 Sep 2018 14:23:10 +0000 (09:23 -0500)]
Merge "channel.c:  Address stack overflow in does_id_conflict()"

14 months agortp_engine: rtcp_report_to_json can overflow the ssrc integer value
Kevin Harwell [Mon, 17 Sep 2018 20:35:05 +0000 (15:35 -0500)]
rtp_engine: rtcp_report_to_json can overflow the ssrc integer value

When writing an RTCP report to json the code attempts to pack the "ssrc" and
"source_ssrc" unsigned integer values as a signed int value type. This of course
means if the ssrc's unsigned value is greater than that which can fit into a
signed integer value it gets converted to a negative number. Subsequently, the
negative value goes out in the json report.

This patch now packs the value as a json_int_t, which is the widest integer type
available on a given system. This should make it so the value no longer
overflows.

Note, this was caught by two failing tests hep/rtcp-receiver/ and
hep/rtcp-sender.

Change-Id: I2af275286ee5e795b79f0c3d450d9e4b28e958b0

14 months agoapp_voicemail: Fix stack overrun in append_mailbox
George Joseph [Fri, 21 Sep 2018 19:32:52 +0000 (13:32 -0600)]
app_voicemail:  Fix stack overrun in append_mailbox

The append_mailbox function wasn't calculating the correct length
to pass to ast_alloca and it wasn't handling the case where context
might be empty.

Found by the Address Sanitizer.

Change-Id: I7eb51c7bd18a7a8dbdba261462a95cc69e84f161

14 months agochannel.c: Address stack overflow in does_id_conflict()
George Joseph [Fri, 21 Sep 2018 20:23:34 +0000 (14:23 -0600)]
channel.c:  Address stack overflow in does_id_conflict()

does_id_conflict() was passing a pointer to an int to a callback
that expected a pointer to a size_t.

Found by the Address Sanitizer.

Change-Id: I0ff542067eef63a14a60301654d65d34fe2ad503

14 months agores_rtp_asterisk: Fix crash on ast_rtp_new failure.
Corey Farrell [Fri, 21 Sep 2018 15:19:52 +0000 (11:19 -0400)]
res_rtp_asterisk: Fix crash on ast_rtp_new failure.

ast_rtp_new free'd rtp upon failure, but rtp_engine.c would also call
the destroy callback.  Remove call to ast_free from ast_rtp_new, leave
it to rtp_engine.c to initiate the full cleanup.  Add error detection
for the ssrc_mapping vector initialization.  In rtp_allocate_transport
set rtp->s = -1 in the failure path where we close that FD to ensure we
don't try closing it twice.

ASTERISK-27854 #close

Change-Id: Ie02aecbb46228ca804e24b19cec2bb6f7b94e451

14 months agores_rtp_asterisk: Reset all settings on module reload
Sean Bright [Thu, 20 Sep 2018 20:26:55 +0000 (16:26 -0400)]
res_rtp_asterisk: Reset all settings on module reload

'rtpchecksums' and 'rtcpinterval' are not being reset to their defaults
if they are not present in the updated configuration file.

Change-Id: I1162e40199314d46cf3225d5e1271c4c81176670

14 months agostasis: Add function to delete topic from pool
George Joseph [Thu, 20 Sep 2018 14:41:15 +0000 (08:41 -0600)]
stasis:  Add function to delete topic from pool

There's been a long standing leak when using topic pools.  The
topics in the pool get cleaned up when the last pool reference is
released but you can't remove a topic specifically.  If you reloaded
app_voicemail for instance, and mailboxes went away, their topics
were left in the pool.

* Added stasis_topic_pool_delete_topic() so modules can clean up
  topics from pools.
* Registered the topic pool containers so it can be examined from
  the CLI when AO2_DEBUG is enabled.  They'll be named
  "<topic_pool_name>-pool".

Change-Id: Ib7957951ee5c9b9b4482af7b9b4349112d62bc25

14 months agoMerge "stasis: No need to keep a stasis type ref in a stasis msg or cache object."
George Joseph [Thu, 20 Sep 2018 18:08:45 +0000 (13:08 -0500)]
Merge "stasis: No need to keep a stasis type ref in a stasis msg or cache object."

14 months agoAST-2018-009: Fix crash processing websocket HTTP Upgrade requests
Sean Bright [Thu, 16 Aug 2018 15:45:53 +0000 (11:45 -0400)]
AST-2018-009: Fix crash processing websocket HTTP Upgrade requests

The HTTP request processing in res_http_websocket allocates additional
space on the stack for various headers received during an Upgrade request.
An attacker could send a specially crafted request that causes this code
to overflow the stack, resulting in a crash.

* No longer allocate memory from the stack in a loop to parse the header
values.  NOTE: There is a slight API change when using the passed in
strings as is.  We now require the passed in strings to no longer have
leading or trailing whitespace.  This isn't a problem as the only callers
have already done this before passing the strings to the affected
function.

ASTERISK-28013 #close

Change-Id: Ia564825a8a95e085fd17e658cb777fe1afa8091a

14 months agoMerge "stasis_cache: Stop caching stasis subscription change messages"
Joshua Colp [Thu, 20 Sep 2018 14:43:26 +0000 (09:43 -0500)]
Merge "stasis_cache:  Stop caching stasis subscription change messages"

14 months agochan_sip.c: chan_sip unstable with TLS after asterisk start or reloads
hajekd [Mon, 3 Sep 2018 14:55:04 +0000 (16:55 +0200)]
chan_sip.c: chan_sip unstable with TLS after asterisk start or reloads

Fixes random asterisk crash on start or reload with TLS phones.

ASTERISK-28034 #close
Reported-by: David Hajek

Change-Id: I2a859f97dc80c348e2fa56e918214ee29521c4ac

14 months agoMerge "pjproject: Update initial 2.8 patches to apply cleanly."
Joshua Colp [Thu, 20 Sep 2018 11:49:52 +0000 (06:49 -0500)]
Merge "pjproject: Update initial 2.8 patches to apply cleanly."

14 months agores_remb_modifier: Add module for controlling REMB from CLI.
Joshua Colp [Thu, 20 Sep 2018 09:48:38 +0000 (09:48 +0000)]
res_remb_modifier: Add module for controlling REMB from CLI.

This adds a module which registers a CLI command that can set the
REMB bitrate value for REMB as it enters or exits Asterisk. This
allows you to ignore what Asterisk or a client produces and is
useful for demonstrations.

This does not generate REMB frames, however, but just modifies
them as they flow to or from a channel.

Change-Id: Ib089427c46a4a36d645cecfe02406adb38c17bec

14 months agoMerge "app_voicemail: Remove need to subscribe to stasis"
Joshua Colp [Thu, 20 Sep 2018 09:53:18 +0000 (04:53 -0500)]
Merge "app_voicemail: Remove need to subscribe to stasis"

14 months agoMerge "install_prereq: Remove unpackaged version of jansson."
Richard Mudgett [Wed, 19 Sep 2018 19:11:40 +0000 (14:11 -0500)]
Merge "install_prereq: Remove unpackaged version of jansson."

14 months agostasis: No need to keep a stasis type ref in a stasis msg or cache object.
Richard Mudgett [Fri, 14 Sep 2018 20:51:41 +0000 (15:51 -0500)]
stasis: No need to keep a stasis type ref in a stasis msg or cache object.

Stasis message types are global ao2 objects and we make stasis messages
and cache entries hold references to them.  Since there are currently
situations where cache objects are never deleted, the reference count on
the types can exceed 100000 and generate a FRACK assertion message.  The
stasis message cache could conceivably also have that many messages
legitimately on large systems.

The only down side to not holding the message type ref in the stasis
message is it only makes a crash either at shutdown or when manually
unloading a busy module slightly more likely.  However, this is more
exposing a pre-existing stasis shutdown ordering issue than a problem with
not holding a message type ref in stasis messages.

* Made stasis messages and cache entries no longer hold a ref to the
message type.

Change-Id: Ibaa28efa8d8ad3836f0c65957192424c7f561707

14 months agopjproject: Update initial 2.8 patches to apply cleanly.
Richard Mudgett [Tue, 18 Sep 2018 18:59:21 +0000 (13:59 -0500)]
pjproject: Update initial 2.8 patches to apply cleanly.

ASTERISK-28059

Change-Id: I027472f2753391646dde594a709a75f14422db93

14 months agoMerge "alembic: fix suppress_q850_reason_headers column name"
Joshua Colp [Wed, 19 Sep 2018 14:36:35 +0000 (09:36 -0500)]
Merge "alembic: fix suppress_q850_reason_headers column name"

14 months agoMerge "res_pjsip_session: Don't add declined stream if one does not exist."
Joshua Colp [Wed, 19 Sep 2018 13:42:37 +0000 (08:42 -0500)]
Merge "res_pjsip_session: Don't add declined stream if one does not exist."

14 months agoMerge "pjproject: Upgrade to 2.8."
George Joseph [Wed, 19 Sep 2018 13:06:03 +0000 (08:06 -0500)]
Merge "pjproject: Upgrade to 2.8."

14 months agostasis_message.c: Don't create immutable stasis objects with locks.
Richard Mudgett [Fri, 14 Sep 2018 20:48:24 +0000 (15:48 -0500)]
stasis_message.c: Don't create immutable stasis objects with locks.

* Create the stasis message object without a lock as it is immutable.
* Create the stasis message type object without a lock as it is immutable.
* Creating the stasis message type could crash if the passed in type name
is NULL and REF_DEBUG is enabled.  Added missing NULL check when passing
the ao2 object tag string.

Change-Id: I28763c58bb9f0b427c11971d0103bf94055e7b32

14 months agopjproject: Upgrade to 2.8.
Joshua Colp [Mon, 17 Sep 2018 16:38:19 +0000 (16:38 +0000)]
pjproject: Upgrade to 2.8.

This change brings in PJSIP 2.8, removes all the patches
that were merged upstream, and makes a minor change to
support a breaking change that was done.

ASTERISK-28059

Change-Id: I5097772b11b0f95c3c1f52df6400158666f0a189

14 months agoalembic: fix suppress_q850_reason_headers column name
Florian Floimair [Tue, 18 Sep 2018 14:39:05 +0000 (16:39 +0200)]
alembic: fix suppress_q850_reason_headers column name

In the original commit introducing the feature the column in the alembic
script was called 'suppress_q850_reason_header'.
In the code however the option is called 'suppress_q850_reason_headers'
(trailing 's'). This leads to errors when ARI push configuration is used.

Change-Id: Ie84808adbca6fcc9136556e4f5d741adbef5d14f

14 months agoapp_voicemail: Remove need to subscribe to stasis
George Joseph [Thu, 13 Sep 2018 12:55:20 +0000 (06:55 -0600)]
app_voicemail: Remove need to subscribe to stasis

app_voicemail was using the stasis cache to build and maintain a
list of mailboxes that had subscribers.  It then used this list
to determine if a mailbox should be polled for new messages if
polling was enabled.  For this to work, stasis had to cache every
subscription and unsubscription to the mailbox which caused a lot of
overhead, both cpu and memory related.

Since polling is only required when changes are being made to
mailboxes outside of app_voicemail and since the number of mailboxes
that don't have any subscribers is likely to be very low, all
mailboxes are now polled instead of just the ones with subscribers.

This paves the way for disabling the caching of stasis subscription
change messages.

Also fixed cleanup in some of the unit tests that not only left
test users in the users list but also caused segfaults if the tests
were run more than once.

ASTERISK-27121

Change-Id: I5cceb737246949f9782955c64425b8bd25a9e9ee

14 months agores_pjsip_session: Don't add declined stream if one does not exist.
Joshua Colp [Tue, 18 Sep 2018 11:08:24 +0000 (11:08 +0000)]
res_pjsip_session: Don't add declined stream if one does not exist.

Given a scenario where a session refresh was done with a removed
stream we would always add a removed stream to the outgoing SDP
even if one did not already exist.

This change makes it so that a removed stream is only placed into
the SDP if one already exists.

ASTERISK-28047

Change-Id: Ibb97d21cdeb87a8acae0c720861b0ff255708442

14 months agoinstall_prereq: Remove unpackaged version of jansson.
Corey Farrell [Mon, 10 Sep 2018 15:12:55 +0000 (11:12 -0400)]
install_prereq: Remove unpackaged version of jansson.

This is removed in favor of ./configure --with-jansson-bundled.  The
install-unpackaged command would only install jansson once, so once
installed it would never update, where the bundled copy will be kept up
to date.

Change-Id: Ideab1f65419608d3795aa608e9da873823cc42d3

14 months agoautoconf: Check for srtp_get_version_string() before using it
Sean Bright [Mon, 17 Sep 2018 15:38:28 +0000 (11:38 -0400)]
autoconf: Check for srtp_get_version_string() before using it

Change-Id: Id2a916ff9448706090e72ff2c7fb3f5ba24a05df

14 months agoMerge "res_srtp.c: Show linked version of libsrtp on module init"
George Joseph [Mon, 17 Sep 2018 14:23:52 +0000 (09:23 -0500)]
Merge "res_srtp.c: Show linked version of libsrtp on module init"

14 months agoMerge "res_pjsip: Log IPv6 addresses correctly"
George Joseph [Mon, 17 Sep 2018 13:34:02 +0000 (08:34 -0500)]
Merge "res_pjsip: Log IPv6 addresses correctly"

14 months agoCI: Fix typo in testsuite git checkout
George Joseph [Mon, 17 Sep 2018 12:10:18 +0000 (06:10 -0600)]
CI: Fix typo in testsuite git checkout

Change-Id: I30024515e5b00a5044fd39fbff27d818f016b719

14 months agores_srtp.c: Show linked version of libsrtp on module init
Sean Bright [Sun, 16 Sep 2018 11:08:29 +0000 (07:08 -0400)]
res_srtp.c: Show linked version of libsrtp on module init

Change-Id: Ib0a645d6985de5757cc4399ed2524b2d02c4f342

14 months agores_pjsip: Log IPv6 addresses correctly
Sean Bright [Fri, 7 Sep 2018 14:40:05 +0000 (10:40 -0400)]
res_pjsip: Log IPv6 addresses correctly

Both pjsip_tx_data.tp_info.dst_name and pjsip_rx_data.pkt_info.src_name
store IPv6 addresses without enclosing brackets. This causes some log
output to be confusing because it is difficult to separate the IPv6
address from a port specification.

* Use pj_sockaddr_print() along with pjsip_tx_data.tp_info.dst_addr and
  pjsip_rx_data.pkt_info.src_addr where possible for consistent IPv6
  output.

* When a pj_sockaddr is not available, explicitly wrap IPv6 addresses
  in brackets.

* When assigning pjsip_rx_data.pkt_info.src_name ourselves, make sure
  to also set pjsip_rx_data.pkt_info.src_addr.

Change-Id: I5cfe997ced7883862a12b9c7d8551d76ae02fcf8

14 months agoCI: Use proper credentials for Security testsuite checkout
George Joseph [Fri, 14 Sep 2018 17:31:28 +0000 (11:31 -0600)]
CI: Use proper credentials for Security testsuite checkout

Can't do anonymous http checkout from Security-testsuite.
Need to use same credentials as the gerrit review checkout.

Change-Id: I87af68c995cb8926f5e87f9af245600d76984f05

14 months agoMerge "res_musiconhold.c: Restart MOH if previous hold just reached end-of-file"
George Joseph [Fri, 14 Sep 2018 16:11:47 +0000 (11:11 -0500)]
Merge "res_musiconhold.c: Restart MOH if previous hold just reached end-of-file"

14 months agostasis_cache: Stop caching stasis subscription change messages
George Joseph [Thu, 13 Sep 2018 16:06:00 +0000 (10:06 -0600)]
stasis_cache:  Stop caching stasis subscription change messages

Since app_voicemail no longer uses the cache to maintain its state
there is no longer a need to cache these messages.

ASTERISK-27121

Change-Id: I321c708505f5ad8d00e1b0afc4c27dc2ac12ecb4

14 months agoMerge "optional_api: Remove unused nonoptreq fields"
Jenkins2 [Thu, 13 Sep 2018 18:08:10 +0000 (13:08 -0500)]
Merge "optional_api: Remove unused nonoptreq fields"

14 months agoMerge "CI: Use .gitreview to default BRANCH_NAME."
Joshua Colp [Thu, 13 Sep 2018 14:00:15 +0000 (09:00 -0500)]
Merge "CI: Use .gitreview to default BRANCH_NAME."

14 months agoMerge "res_pjproject: Fix sockaddr conversion routines for non-bundled PJSIP"
Joshua Colp [Thu, 13 Sep 2018 12:11:40 +0000 (07:11 -0500)]
Merge "res_pjproject: Fix sockaddr conversion routines for non-bundled PJSIP"

14 months agoMerge "Build System: Resolve conflict between DESTDIR and bundled jansson."
Joshua Colp [Wed, 12 Sep 2018 22:19:24 +0000 (17:19 -0500)]
Merge "Build System: Resolve conflict between DESTDIR and bundled jansson."

14 months agoCI: Use .gitreview to default BRANCH_NAME.
Corey Farrell [Wed, 12 Sep 2018 17:39:23 +0000 (13:39 -0400)]
CI: Use .gitreview to default BRANCH_NAME.

This ensures that binary modules are avoided in the master branch even
if BRANCH_NAME is not set.

Change-Id: I79162d2063f22fa9d6b31fde4827ace2dd5bf0da

14 months agooptional_api: Remove unused nonoptreq fields
Walter Doekes [Tue, 11 Sep 2018 12:22:18 +0000 (14:22 +0200)]
optional_api: Remove unused nonoptreq fields

As they're not actively used, they only grow stale. The moduleinfo field itself
is kept in Asterisk 13/15 for ABI compatibility.

ASTERISK-28046 #close

Change-Id: I8df66a7007f807840414bb348511a8c14c05a9fc

14 months agoMerge "manager: Set AMI event "Newexten" to the EVENT_FLAG_DIALPLAN class"
Joshua Colp [Wed, 12 Sep 2018 16:01:25 +0000 (11:01 -0500)]
Merge "manager: Set AMI event "Newexten" to the EVENT_FLAG_DIALPLAN class"

14 months agomanager: Set AMI event "Newexten" to the EVENT_FLAG_DIALPLAN class
lvl [Mon, 3 Sep 2018 11:50:07 +0000 (13:50 +0200)]
manager: Set AMI event "Newexten" to the EVENT_FLAG_DIALPLAN class

The documentation already specified EVENT_FLAG_DIALPLAN for this
event, but the implementation was using EVENT_FLAG_CALL.

Using EVENT_FLAG_DIALPLAN allows AMI clients to opt out of receiving
this highly verbose event.

ASTERISK-28033

Change-Id: I45b3119f30e4dbc17b49831f2b1a4f2c1beadafe

14 months agores_pjproject: Fix sockaddr conversion routines for non-bundled PJSIP
Sean Bright [Wed, 12 Sep 2018 12:18:07 +0000 (08:18 -0400)]
res_pjproject: Fix sockaddr conversion routines for non-bundled PJSIP

The bundled version of pjproject has a patch for Solaris compatability
that changes the definition of various socket structures which we need
to account for when compiling against a non-bundled version.

ASTERISK-28049 #close

Change-Id: Ia1ea47c433fc2d915115193ee889a752373925f0

14 months agoBuild System: Resolve conflict between DESTDIR and bundled jansson.
Corey Farrell [Tue, 11 Sep 2018 03:28:04 +0000 (23:28 -0400)]
Build System: Resolve conflict between DESTDIR and bundled jansson.

If Asterisk is built using a DESTDIR this will cause the bundled jansson
to be installed to an unexpected location and we will fail to find it.

Change-Id: Id033e2813261e0d45232383d44c6391122169548

15 months agores_musiconhold.c: Restart MOH if previous hold just reached end-of-file
Frederic LE FOLL [Thu, 30 Aug 2018 08:42:18 +0000 (10:42 +0200)]
res_musiconhold.c: Restart MOH if previous hold just reached end-of-file

On MOH activation, moh_files_readframe() is called while the current
stream attached to the channel is NULL and it calls ast_moh_files_next()
immediately.  However, it won't call ast_moh_files_next() again if sample
reading fails.  The failure may occur because res_musiconhold retains the
last sample reading position in the channel data and MOH during the
previous hold/retrieve just reached EOF.  Obviously, a bit of bad luck is
required here.

* Restructured moh_files_readframe() to try a second time to start MOH if
there was no stream setup and the saved position was at EOF.  Also added
comments describing what is going on for each step.

ASTERISK-28029

Change-Id: I1508cf2c094f8feca22d6f76deaa9fdfa9944860

15 months agoMerge "core: Don't stop generators when writing RTCP frames."
Jenkins2 [Fri, 7 Sep 2018 12:02:38 +0000 (07:02 -0500)]
Merge "core: Don't stop generators when writing RTCP frames."

15 months agoMerge "stasis_cache: Prune stasis_subscription_change messages"
Joshua Colp [Fri, 7 Sep 2018 10:40:36 +0000 (05:40 -0500)]
Merge "stasis_cache: Prune stasis_subscription_change messages"