Commit Graph

32633 Commits

Author SHA1 Message Date
Pirmin Walthert 6b2d945174 app.c: make sure that no non-async-signal-safe syscalls are used after
fork before exec

Posix does only allow async-signal-safe syscalls after fork before exec.
As asterisk ignores this, functions like TrySystem or System sometimes
end up in a deadlocked child process. The patch prevents the use of
non-async-signal-safe syscalls.

ASTERISK-28776

Change-Id: Idc76365c0592ee3f3b3bd72a4f48f7a098978e8e
2020-05-08 13:44:08 -05:00
George Joseph 7fbfbe7da0 streams: Fix one memory leak and one formats ref issue
ast_stream_topology_create_from_format_cap() was setting the
stream->formats directly but not freeing the default formats.  This
causes a memory leak.

* ast_stream_topology_create_from_format_cap() now calls
  ast_stream_set_formats() which properly cleans up the existing
  stream formats.

When cloning a stream, the source stream's format caps _pointer_ is
copied to the new stream and it's reference count bumped.  If
either stream is set to "removed", this will cause _both_ streams
to have their format caps cleared.

* ast_stream_clone() now creates a new format caps object and copies
  the formats from the source stream instead of just copying the
  pointer.

ASTERISK-28870

Change-Id: If697d81c3658eb7baeea6dab413b13423938fb53
2020-05-06 07:32:15 -05:00
Nathan Bruning f217fcdc62 app_queue: track masquerades in app_queue to avoid leaked stasis subscriptions
Add a new "masquarade" channel event, and use it in app_queue to track unique id's.

Testcase is submitted as https://gerrit.asterisk.org/c/testsuite/+/14210

ASTERISK-28829 #close
ASTERISK-25844 #close

Change-Id: Ifc5f9f9fd70903f3c6e49738d3bc632b085d2df6
2020-05-06 04:10:26 -05:00
Jaco Kroon 44e5dd288b Remove #include <sys/cdefs.h>
These are not provided by standards, and as a result causes failure to
compile on musl.

https://wiki.musl-libc.org/faq.html#Q:-When-compiling-something-against-musl,-I-get-error-messages-about-%3Ccode%3Esys/cdefs.h%3C/code%3E

Change-Id: I6a357cefd106c72cfecafd898638f6b5692c2e05
2020-05-05 10:06:43 -05:00
Guido Falsi c831f03273 pjproject: Remove bashism from configure.m4 script
The configure.m4 script for pjproject contains some += syntax, which
is specific to bash, replacing it with string substitutions makes
the script compatible with traditional Bourne shells.

ASTERISK-28866 #close
Reported-by: Christoph Moench-Tegeder <cmt@FreeBSD.org>

Change-Id: I382a78160e028044598b7da83ec7e1ff42b91c05
2020-05-05 09:28:01 -05:00
Joshua C. Colp 1cfd30bd8a res_stir_shaken: Use ast_asprintf for creating file path.
Change-Id: Ice5d92ecea2f1101c80487484f48ef98be2f1824
2020-05-01 10:17:15 -03:00
Ben Ford 9acf840f7c res_stir_shaken: Implemented signature verification.
There are a lot of moving parts in this patch, but the focus of it is on
the verification of the signature using a public key located at the
public key URL provided in the JSON payload. First, we check the
database to see if we have already downloaded the key. If so, check to
see if it has expired. If it has, redownload from the URL. If we don't
have an entry in the database, just go ahead and download the public
key. The expiration is tested each time we download the file. After
that, read the public key from the file and use it to verify the
signature. All sanity checking is done when the payload is first
received, so the verification is complete once this point is reached.

The XML has also been added since a new config option was added to
general (curl_timeout). The maximum amount of time to wait for a
download can be configured through this option, with a low value by
default.

Change-Id: I3ba4c63880493bf8c7d17a9cfca1af0e934d1a1c
2020-05-01 06:31:46 -05:00
George Joseph 7baf2c4bf1 app_voicemail: Add workaround for a gcc 10 issue with -Wrestrict
The gcc 10 -Wrestrict option was causing "overlap" errors when
snprintf was copying one char[256] structure member to another
char[256] member in the same structure.

Using ast_alloca instead of declaring the structure inline
solves the issue.

Here's a link to the "enhancement":
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-10/msg00570.html

We may follow up with a gcc bug report.

Change-Id: Ie0099adcb0a9727bd9aa99e024dd912a67eaf534
2020-04-30 11:10:23 -05:00
Joshua C. Colp 3078a00a6d pjsip: Increase maximum ICE candidate count.
In practice it has been seen that some users come
close to our maximum ICE candidate count of 32.
In case people have gone over this increases the
count to 64, giving ample room.

ASTERISK-28859

Change-Id: I35cd68948ec0ada86c14eb53092cdaf8b62996cf
2020-04-29 13:53:01 -05:00
Alexander Traud 29070b61f7 core_local: Local calls are always secure.
In a Dialplan, the channel drivers 'chan_sip' and 'chan_iax2' support
the channel items 'secure_bridge_media' and 'secure_bridge_signaling'.
That way, a channel can be forced to use encryption even if not
specified in its configuration.

However, when the Local Proxy kicks in, for example, in case of a
forwarding (SIP status 302), Local Proxy stated it does not know those
items. Consequently, such a call could not be proxied how clever your
Dialplan was. Because local calls within Asterisk are always secure,
Local Proxy accepts such a request now.

ASTERISK-22920

Change-Id: I4c143bb70f686790953cc04c5a4b810bbb03636c
2020-04-29 13:08:07 -05:00
Guido Falsi e4366308e1 res_rtp_asterisk: Protect access to nochecksums with #ifdef
Recently code accessing nochecksums variable has been added without including #ifdef SO_NO_CHECK protection, while the variable is created only when such constant is defined.

ASTERISK-28852 #close

Change-Id: I381718893b80599ab8635f2b594a10c1000d595e
2020-04-28 13:57:20 -05:00
Guido Falsi 97494d8984 core/dns: Add system include required on FreeBSD
While testing the latest RC on FreeBSD I noticed this new file fails to build. On FreeBSD inlcuding resolv.h requires sockaddr_in to be defined, and it's defined in netinet/in.h. So I added this include.

ASTERISK-28853 #close

Change-Id: I6997daf3956e6eb70ab6cb358628d162fad80079
2020-04-28 13:05:55 -05:00
Peter Turczak 3303defd3f chan_mobile: Add smoother to make SIP/RTP endpoints happy.
In contrast to RFC 3551, section 4.2, several SIP/RTP clients misbehave
severly (up to crashing). This patch adds another smoother for the audio
received via bt. Therefore the audio frames sent to the core will be
CHANNEL_FRAME_SIZE.

ASTERISK-28832 #close

Change-Id: Ic5f9e2f35868ae59cc9356afbd1388b779a1267f
2020-04-27 09:40:38 -05:00
Alexander Traud 26b8c99963 app_fax: SpanDSP headers do not use ast_malloc; ignore that.
Since Asterisk 14, app_fax did not compile at all because Asterisk
requires that not malloc but ast_malloc is used everywhere. However,
the system headers of SpanDSP use malloc. Because we cannot (and do
not need to) change system headers, let us ignore this.

ASTERISK-28848

Change-Id: I31f7a6b92a07032c5cef1c16b8901b107fe35546
2020-04-24 05:18:31 -05:00
Joshua C. Colp 1c5e68580a stream: Enforce formats immutability and ensure formats exist.
Some places in Asterisk did not treat the formats on a stream
as immutable when they are.

The ast_stream_get_formats function is now const to enforce this
and parts of Asterisk have been updated to take this into account.
Some violations of this were also fixed along the way.

An additional minor tweak is that streams are now allocated with
an empty format capabilities structure removing the need in various
places to check that one is present on the stream.

ASTERISK-28846

Change-Id: I32f29715330db4ff48edd6f1f359090458a9bfbe
2020-04-23 09:16:51 -05:00
sungtae kim 9ad3d2829c res_ari_channels: Fixed endpoint 80 characters limit
Fixed it to copy the entire string from the requested endpoint body except tech-prefix.

ASTERISK-28847

Change-Id: I91b5f6708a1200363f3267b847dd6a0915222c25
2020-04-22 16:07:22 -05:00
Joshua C. Colp e56f4de7e6 fax: Fix crashes in PJSIP re-negotiation scenarios.
This change fixes a few re-negotiation issues
uncovered with fax.

1. The fax support uses its own mechanism for
re-negotiation by conveying T.38 information in
its own frames. The new support for re-negotiating
when adding/removing/changing streams was also
being triggered for this causing multiple re-INVITEs.
The new support will no longer trigger when
transitioning between fax.

2. In off-nominal re-negotiation cases it was
possible for some state information to be left
over and used by the next re-negotiation. This
is now cleared.

ASTERISK-28811
ASTERISK-28839

Change-Id: I8ed5924b53be9fe06a385c58817e5584b0f25cc2
2020-04-22 10:09:00 -05:00
DanielYK 9f117ac9ef res_pjsip: Fixed format of IPv6 addresses for external media addresses
ASTERISK-28835

Change-Id: I66289afd164c5cdd6c5caa39e79d629a467e7a26
2020-04-21 17:45:42 -05:00
Alexander Traud 52f07176b6 chan_sip: externhost/externaddr with non-default TCP/TLS ports.
ASTERISK-28372
Reported by: Anton Satskiy

ASTERISK-24428
Reported by: sstream

Change-Id: I2b7432a9bf3b09dc8515297ff955636db7a6224c
2020-04-21 10:20:26 -05:00
Alexander Traud abf4d74384 cdr_odbc: Sync load- and build-time deps.
MODULEINFO is checked while buidling/linking the module.
AST_MODULE_INFO is checked while loading/running the module.

ASTERISK-28838

Change-Id: I55dc05ce19552d0415c9045021b42bd82ef44e52
2020-04-20 12:06:05 -05:00
Joshua C. Colp 6cfc6ff53c confbridge: Add support for disabling text messaging.
When in a conference bridge it may be necessary to have
text messages disabled for specific participants or for
all. This change adds a configuration option, "text_messaging",
which can be used to enable or disable this on the
user profile. By default existing behavior is preserved
as it defaults to "yes".

ASTERISK-28841

Change-Id: I30b5d9ae6f4803881d1ed9300590d405e392bc13
2020-04-20 12:03:22 -05:00
Alexander Traud 191f136260 res_pjsip_refer: Add build-time dependency.
ASTERISK-28838

Change-Id: Ic693c3f464e35ec0db242afdb0a1415806af4e25
2020-04-20 11:04:09 -05:00
Alexander Traud 5c2b8fdeca app_getcpeid: Add build-time dependency.
ASTERISK-28838

Change-Id: I68b78e7e4718be82507247433127ce3992a5ba96
2020-04-20 11:03:46 -05:00
Alexander Traud 008f46bf1e res_pjsip: Sync load- and build-time deps.
MODULEINFO is checked while buidling/linking the module.
AST_MODULE_INFO is checked while loading/running the module.

ASTERISK-28838

Change-Id: I4bb868532ca217fec1351885d99eb55c21b58042
2020-04-20 11:03:26 -05:00
Alexander Traud e2affa3b0a curl: Add build-time dependency.
ASTERISK-28838

Change-Id: I34724e799e1ffaf723eb2c358abe8934dbadcd52
2020-04-20 09:55:45 -05:00
Alexander Traud f1135b453b res_pjsip: Add build-time dependency.
ASTERISK-28838

Change-Id: Icb08304744ae3f34dce6ccb76f94379b8382a074
2020-04-20 09:12:40 -05:00
Alexander Traud 966acc6251 pjproject_bundled: Honor --without-pjproject.
ASTERISK-28837

Change-Id: Id057324912a3cfe6f50af372675626bb515907d9
2020-04-17 06:35:06 -05:00
Pirmin Walthert d50fd0acc0 res_rtp_asterisk: Resolve loop when receive buffer is flushed
When the receive buffer was flushed by a received packet while it
already contained a packet with the same sequence number, Asterisk
never left the while loop which tried to order the packets.

This change makes it so if the packet is in the receive buffer it
is retrieved and freed allowing the buffer to empty.

ASTERISK-28827

Change-Id: Idaa376101bc1ac880047c49feb6faee773e718b3
2020-04-17 06:11:19 -05:00
Alexander Traud a107e85b2e install_prereq: Add libcap for high bits in DiffServ/ToS.
works automatically; see Mantis 7047 (now ASTERISK-6863)

Change-Id: I27d2c109180bd857b6757fd532de48eddb78aee6
2020-04-16 10:29:30 -05:00
Alexander Traud 4d0ab620be chan_sip: DiffServ/ToS not only on UDP but also on TCP and TLS sockets.
ASTERISK-27195
Reported by: Joshua Roys

Change-Id: I6e72ecb874200dec7a3865c7babaf5ac0d3101de
2020-04-16 10:20:36 -05:00
Alexander Traud 4ef5ba58f5 BuildSystem: Only if found LibPRI, check its optional parts.
Change-Id: If8445f899ee4ce0c606c484943d4ce0c8e43b5da
2020-04-16 09:53:29 -05:00
Pirmin Walthert ca032d1e2e res_rtp_asterisk: Free payload when error on insertion to data buffer
When the ast_data_buffer_put rejects to add a packet, for example because
the buffer already contains a packet with the same sequence number, the
payload will never be freed, resulting in a memory leak.

The data buffer will now return an error if this situation occurs
allowing the caller to free the payload. The res_rtp_asterisk module
has also been updated to do this.

ASTERISK-28826

Change-Id: Ie6c49495d1c921d5f997651c7d0f79646f095cf1
2020-04-15 13:56:40 -05:00
Alexander Traud ef580f96e7 BuildSystem: Only if found external PJProject, check its optional parts.
Change-Id: I11d5693d25c166c99d8cebffc16184d58f6362de
2020-04-15 11:26:57 -05:00
bernard merindol 7db03e12a7 res_rtp_asterisk.c: Check for first DTMF having timestamp set to 0
When the first DTMF receive in RF2833 codec have TimeStamp at 0
is not processed.

ASTERISK-28812

Change-Id: I3196803a062dd2daee4938c9a778c3810cb7e504
2020-04-14 10:28:51 -05:00
Alexander Traud 611529fa52 res_stir_shaken: Do not build without OpenSSL.
Change-Id: Idba5151a3079f9dcc0076d635422c5df5845114f
2020-04-14 09:50:55 -05:00
Alexander Traud 27de0c9700 res_audiosocket: Avoid Sometimes-uninitialized Warning with Clang.
Change-Id: I40c014c2cb88e943cf6f1b99a08c7c885e855b3a
2020-04-14 09:47:22 -05:00
Jean Aunis de66713fd5 func_volume: Accept decimal number as argument
Allow voice volume to be multiplied or divided by a floating point number.

ASTERISK-28813

Change-Id: I5b42b890ec4e1f6b0b3400cb44ff16522b021c8c
2020-04-14 09:28:05 -05:00
Jaco Kroon 2b80e5f5da res_rtp_asterisk: iterate all local addresses looking to populate ICE.
By using pjproject to give us a list of candidates, and then filtering,
if the host has >32 addresses configured, then it is possible that we
end up filtering out all 32 of those, and ending up with no candidates
at all.  Instead, get getifaddrs (which pjsip is using underlying
anyway) to retrieve all local addresses, and iterate those, adding the
first 32 addresses not excluded by the ICE ACL.

In our setup at any point in time We've got between 6 and 328 addresses
on any given system.  The lower limit is the lower limit but the upper
limit is growing on a near daily basis currently.

Change-Id: I109eaffc3e2b432f00bf958e3caa0f38cacb4edb
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2020-04-13 19:43:54 -05:00
Alexander Traud 3431949a52 pjproject_bundled: Repair ./configure --with-ssl without ARG.
ASTERISK-28758
Reported by: Patrick Wakano
Reported by: Dmitriy Serov

Change-Id: Ifb6b85c559d116739af00bc48d1f547caa85efac
2020-04-13 18:22:35 -05:00
Jaco Kroon 1cf569ba2b res_pjsip: document legal dtls_verify endpoint options.
Change-Id: I7fa7c5c8a7ddb0bd525982f58bff3264ebbd9a1b
2020-04-13 17:31:20 -05:00
Alexander Traud 610e058189 BuildSystem: Search for Python/C API when possibly needed only.
The Python/C API is used only if the Test Framework was enabled in Asterisk
'make menuselect'. The Test Framework is available only if the Developer Mode
was enabled in Asterisk './configure --enable-dev-mode'. And that Python/C API
is used only if the PJProject was found and not disabled in Asterisk; the user
did not go for './configure --without-pjproject'.

Furthermore, because version 2 of that Python/C API is required (currently) and
because some platforms do not offer a generic version 2, the script searches
for 2.7 explicitly as well.

To avoid version mismatch between the Python/C API and the Python environment,
the script searches for the latter in the same versions, in the same the order
as well. Because this Python/C API is just for (some) Asterisk contributors,
the script also goes for the Python 3 environment as a last resort for all
other Asterisk users. This allows 'make full' even on minimal installations of
Ubuntu 18.04 LTS and newer.

Because the Python/C API is Asterisk contributor specific, the Python packages
are removed from the script './contrib/scripts/install_prereq' as this script
is intended for Asterisk users. Asterisk contributors have to install much more
packages in any case, like:
sudo apt install autoconf automake git git-review python2.7-dev

ASTERISK-28824
ASTERISK-27717

Change-Id: Id46d357e18869f64dcc217b8fdba821b63eeb876
2020-04-13 17:21:46 -05:00
traud da9554d925 chan_sip: TCP/TLS client without server.
It is possible to configure a TCP/TLS client without having a TCP/TLS
server. In that case, no error or warning was printed but the headers
Contact and Via in SIP REGISTER were "(null)".

ASTERISK-28798

Change-Id: I387ca5cb6a65f1eb675a29c5e41df8ec6c242ab2
2020-04-13 16:38:43 -05:00
Alexander Traud 52ecbbd014 _pjsua: Build even with Clang.
Change-Id: Iebf7687613aa0295ea3c82256460b337f1595be2
2020-04-13 15:02:19 -05:00
Alexander Traud ee1c7f465b
res_rtp_asterisk: Build without PJProject.
Change-Id: Ifc5059cd867e77b9c92ed9f4b895a9a91200d3ec
2020-04-13 18:27:28 +02:00
Kevin Harwell fa3c8f94e0 chan_pjsip: digit_begin - constant DTMF tone if RTP is not setup yet
If chan_pjsip is configured for DTMF_RFC_4733, and the core triggers a
digit begin before media, or rtp has been setup then it's possible the
outgoing channel will hear a constant DTMF tone upon answering.

This happens because when there is no media, or rtp chan_pjsip notifies
the core to initiate inband DTMF. However, upon digit end if media, and
rtp become available then chan_pjsip does not notify the core to stop
inband DTMF. Thus the tone continues playing.

This patch makes it so chan_pjsip only notifies the core to start
inband DTMF in only the required cases. Now if there is no media, or
rtp availabe upon digit begin chan_pjsip does nothing, but tells the
core it handled it.

ASTERISK-28817 #close

Change-Id: I0dbea9fff444a2595fb18c64b89653e90d2f6eb5
2020-04-13 11:05:20 -05:00
Alexander Traud 7febd22304 bridge_softmix_binaural: Show state in menuselect.
ASTERISK-28819

Change-Id: Iba7ee7bc7936d7a156171c8fc0f1670e864e7600
2020-04-13 10:30:12 -05:00
traud 7cdb493a1e BuildSystem: Remove doc/tex and doc/pdf leftovers.
Furthermore, the nowhere used compress is removed.

ASTERISK-28816

Change-Id: I77daab80cfabb56d51c3ea6b1d14bd9b9fbc577c
2020-04-13 10:24:18 -05:00
Alexander Traud 7a04947abd
BuildSystem: Allow space in path.
ASTERISK-28818

Change-Id: Ib7f246896457d9e3b14d7f5199136d6545ce0b6f
2020-04-09 14:05:54 +02:00
traud 1ef1b1b0c2 res_rtp_asterisk: Avoid absolute value on unsigned subtraction.
ASTERISK-28809

Change-Id: I269731715347c8e5ef7db1b6ffd3f8d15fc04be4
2020-04-08 10:01:42 -05:00
Sebastien Duthil d40e343710 func_channel: allow reading 4 fields from dialplan
The following fields return an error when read from dialplan:

- exten
- context
- userfield
- channame

ASTERISK-28796 #close

Change-Id: Ieacaac629490f8710fdacc9de80ed5916c5f6ee2
2020-04-08 09:47:55 -05:00