This change moves logic for setting up the DTLS SSL contexts to
when the SDP is done being processed instead of when ICE negotiation
completes. It also stops handshakes from being initiated when we
are acting as a server.
Manipulating the SSL context when ICE negotiation has completed
is problematic as the SSL context is not protected and if acting
as a client the remote side may have started DTLS negotiation
already.
The retransmission timeout timer code has also been split up
and simplified some. Both RTP and RTCP now have their own timers
and the points at which the timer is stopped and started is now
more specific. When a packet is sent the timer is started. When
a response is received but before it is processed the timer is
stopped. This provides a guarantee that the timeout is not
occurring while the response is processed.
ASTERISK-22805 #close
ASTERISK-24550 #close
ASTERISK-24651 #close
ASTERISK-24832 #close
ASTERISK-25103 #close
ASTERISK-25127 #close
Change-Id: Ib75ea2546f29d6efc3d2d37c58df6986c7bd9b91
MWI subscriptions can crash or corrupt memory when using the subscription
datastore to access the MWI subscription object because the datastore is
not holding a reference to the object.
* Give the subscription datastore a ref to the MWI subscription object.
It is unfortunate that the ref causes a circular ref chain that must be
explicitly broken to allow the memory to get released. The loop is broken
when the subscription is shutdown and if the subscription setup fails.
ASTERISK-25168 #close
Reported by: Carl Fortin
Change-Id: Ice4fa823f138ff10a6c74d280699c41a82836d4f
When res_pjsip body generator modules were generating XML or XPIDF
response bodies, there was a chance that the generated body would be the
exact size of the supplied buffer. Adding the nul string terminator would
then write beyond the end of the buffer and potentially corrupt memory.
* Fix MALLOC_DEBUG high fence violations caused by adding a nul string
terminator on the end of a buffer for XML or XPIDF response bodies.
* Made calls to pj_xml_print() safer if the XML prolog is requested. Due
to a bug in pjproject, the return value could be -1 _or_
AST_PJSIP_XML_PROLOG_LEN if the supplied buffer is not large enough.
* Updated the doxygen comment of AST_PJSIP_XML_PROLOG_LEN to describe the
return value of pj_xml_print() when the supplied buffer is not large
enough.
ASTERISK-25168
Reported by: Carl Fortin
Change-Id: Id70e1d373a6a2b2bd9e678b5cbc5e55b308981de
When a caller calls a FAX number and then hangs up right after the call is
answered then the T.38 re-INVITE automatic reject timer may still be
running after the channel goes away.
* Added session NULL channel checks on the code paths that get executed by
t38_automatic_reject() to prevent a crash when the T.38 re-INVITE
automatic reject timer expires.
ASTERISK-25168
Reported by: Carl Fortin
Change-Id: I07b6cd23815aedce5044f8f32543779e2f7a2403
Calling t38_change_state() sets the t38 state so it makes little sense to
then check the state right after the call for something else.
* Made the code in t38_interpret_parameters() reject or exit T.38 mode as
intended but not implemented.
Change-Id: Ib281263a6ed44da9448132c4e6df1e183b8a3df2
Previously Asterisk did not properly failover to the next resolved DNS
address when a endpoint could not be reached. With this patch, and while
using res_pjsip, SIP requests (both in/out of dialog) now attempt to use
the next address in the list of resolved addresses until a proper response
is received or no more addresses are left.
ASTERISK-25076 #close
Reported by: Joshua Colp
Change-Id: Ief14f4ebd82474881f72f4538f4577f30af2a764
In Jenkins there is currently a sporadic test failure of a
variable number of sorcery memory cache unit tests. I have not
been able to reproduce this on the build agents themselves or
on my development machine.
My working theory is that the stale unit test is causing a
sorcery instance to persist longer than expected, causing subsequent
tests to fail when setting up and initializing the next
sorcery instance.
To see if this is the case this change moves the stale unit test
to execute last so no subsequent unit tests can have issues
initializing their sorcery instance.
Change-Id: Ifd6550a949613be774b75fa5db12c02110f82c4a
This patch enhances the bucket API in two ways.
First, since ast_bucket and ast_bucket_file instances are immutable, a 'clone'
operation has been added that provides a 'clone' of an existing
ast_bucket/ast_bucket_file object. Note that this makes use of the
ast_sorcery_copy operation, along with the copy callback handler on the
"bucket" and "file" object types for the bucket sorcery instance.
Second, there is a need for the bucket API to ask a wizard if an object
is stale. This is particularly useful with the upcoming media cache
enhancements, where we want to ask the backing data storage if the
object we are currently operating on has known updates. This patch adds
API calls for ast_bucket and ast_bucket_file objects, which callback
into their respective sorcery wizards via the sorcery API.
Unit tests have also been added to cover the respective
ast_bucket/ast_bucket_file clone and staleness operations.
Change-Id: Ib0240ba915ece313f1678a085a716021d75d6b4a
This patch enhances the sorcery API to allow for sorcery wizards to
determine if an object is stale. This includes the following:
* Sorcery objects now have a timestamp that is set on creation. Since
sorcery objects are immutable, this can be used by sorcery wizards to
determine if an object is stale.
* A new API call has been added, ast_sorcery_is_stale. This API call
queries the wizards associated with the object, calling a new callback
function 'is_stale'. Note that if a wizard does not support the new
callback, objects are always assumed to not be stale.
* Unit tests have been added that cover the new API call.
Change-Id: Ica93c6a4e8a06c0376ea43e00cf702920b806064
This change makes it so that when accepting a WebSocket
connection the HTTP response is sent as one packet instead of
fragmented. Browsers don't like it when you send it fragmented.
ASTERISK-25103
Change-Id: I9b82c4ec2949b0bce692ad0bf6f7cea9709e7f69
This patch updates a variety of Makefiles in Asterisk's build system to
remove .gcda and .gcno files when 'make clean' is executed. These files
are generated when '--enable-coverage' is passed to the Asterisk
configure script.
Change-Id: Ib70b41eea2ee2908885bff02e80faf9f40c84602
When handle_invite_replaces() was called, and either ast_bridge_impart()
failed or there was no bridge (because the channel we're picking up was
still ringing), chan_sip would leak a channel.
Thanks Matt and Corey for checking the bridge path.
ASTERISK-25226 #close
Change-Id: Ie736bb182170a73eef5bcef0ab0376f645c260c8
When a mapping does not exist between a sorcery.conf defined object and
a realtime mapping in extconf, currently, the user will receive a slew
of ERROR messages that don't really tell what is happening. Some ERROR
messages may even be misleading, as they occur after the sorcery API has
already given up on the attempt to load and create the sorcery object.
This patch adds a bit of debug and a useful WARNING message for when a
wizard's open callback fails for a particular object type. In the bad
configurations that resulted in this patch, this provided a 'root cause'
WARNING message that pointed in the right direction of the configuration
problem.
Change-Id: I1cc7344f2b015b8b9c85a7e6ebc8cb4753a8f80b
The recurring unit test expects the user data on a DNS query
created as a result of a recurring DNS query to be the recurring
structure itself. This is true, mostly. When invoking the user
provided callback this user data is changed to the user provided
data. This presents a race condition where the data may or may
not point to the recurring data.
This change simplifies the callback of the user provided callback
by creating a new query and populating it with the expected values.
This leaves the recurring DNS query alone and fixes the race
condition. This is more in line with how the API should be used
overall.
ASTERISK-25222 #close
Change-Id: I10fb6deec025dff097157e7ec17e6e4921778478
When running valgrind on Asterisk, it complained about:
==32423== Source and destination overlap in memcpy(0x85a920, 0x85a920, 304)
==32423== at 0x4C2F71C: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/...)
==32423== by 0x55BA91: ast_rtp_engine_unload_format (rtp_engine.c:2292)
==32423== by 0x4EEFB7: ast_format_attr_unreg_interface (format.c:1437)
The code in question is a struct assignment, which may be performed by
memcpy as a compiler optimization. It is changed to only copy the struct
contents if source and destination are different.
ASTERISK-25219 #close
Change-Id: I6d3546c326b03378ca8e9b8cefd41c16e0088b9a
If DEBUG_FD_LEAKS was used and more file descriptors than the default of
1024 were available, some DEBUG_FD_LEAKS-patched functions would
overwrite memory past the fixed-size (1024) fdleaks buffer.
This change:
- adds bounds checks to __ast_fdleak_fopen and __ast_fdleak_pipe
- consistently uses ARRAY_LEN() instead of sizeof() or 1023 or 1024
- stores pointers to constants instead of copying the contents
- reorders the fdleaks struct for possibly tighter packing
- adds a tiny bit of documentation
ASTERISK-25212 #close
Change-Id: Iacb69e7701c0f0a113786bd946cea5b6335a85e5
This fixes so a failure to get a timer file descriptor does not cascade
to closing FD 0.
On error, both res_timing_kqueue and res_timing_timerfd would call the
destructor before setting the file handle. The file handle had been
initialized to 0, causing FD 0 to be closed. This in turn, resulted in
floods of "CLI>" messages and an unusable terminal.
ASTERISK-19277 #close
Reported by: Barry Chern
For the master branch, this was already fixed. This patch only ensures
that we do not attempt to close a negative file descriptor.
Change-Id: I147d7e33726c6e5a2751928d56561494f5800350
When a frame is queued on a channel, any failure in
ast_channel_alert_write is logged along with errno.
This change improves the diagnostic message through
aligning the errno value with actual failure cases.
ASTERISK-25224
Reported by: Andrey Biglari
Change-Id: I1bf7b3337ad392789a9f02c650589cd065d20b5b
This prevents a leak of a sorcery object type when realtime sorcery
objects are retrieved by fields or when multiple objects are retrieved.
The extent of this leak is that sorcery object types would be leaked.
These are allocated whenever an object type is registered with sorcery,
meaning that on module shutdown, these objects would be leaked. This
could be problematic if many reloads were performed, but it is not as
severe as if every sorcery object retrieved from realtime were being
leaked.
ASTERISK-25165 #close
Reported by Corey Farrell
Change-Id: I625c3b50eee4576670b7eeb013c81ad043b4b4f8
Returns a 'failure' from the module load routine indicates to Asterisk
that it should abort loading completely. This is rarely - in fact,
really, never - a good option. Aborting load of Asterisk from a dynamic
module implies that the core, and the rest of the dynamic modules, don't
matter: we should abandon all processing.
res_corosync is really not that important.
This patch updates the module such that, if it fails to load, it
politely declines (emitting ERROR messages along the way), and allows
Asterisk to continue to function.
Note that this issue was keeping Asterisk unit tests from running on
certain build agents.
Change-Id: I252249e81fb9b1a68e0da873f54f47e21d648f0f
When 8297136f was merged for ASTERISK-25040, a regression was introduced
surrounding the case sensitivity of device names within hints.
Previously, device names - such as 'sip/foo' - were compared in a case
insensitive fashion. Thus, 'sip/foo' was equivalent to 'SIP/foo'. After
that patch, only the case sensitive name would match, i.e., 'SIP/foo'.
As a result, some dialplan hints stopped working.
This patch re-introduces case insensitive matching for device names in
hints.
ASTERISK-25040
ASTERISK-25202 #close
Change-Id: If5046a7d14097e1e3c12b63092b9584bb1e9cb4c
(cherry picked from commit 96bbcf495a)
A previous change made the contact only get rewritten if the dialog's
route set was not marked frozen. Unfortunately, while the intent of this
is correct, the dialog's route set actually gets marked as frozen
earlier than expected, especially for UAS dialogs.
Instead, the idea is that the contact needs to not be rewritten if there
is a pre-existing route set on the dialog. This is now accomplished by
checking the dialog's route set list instead of checking if the route
set is frozen.
Doing this causes some broken tests to begin passing again.
ASTERISK-25196
Reported by Mark Michelson
Change-Id: I525ab251fd40a52ede327a52a2810a56deb0529e
The client_state objects contain a serializer used to send the outbound
REGISTER messages. Once all those message transactions are complete then
the module can shutdown.
ASTERISK-24907 #close
Reported by: Kevin Harwell
Change-Id: Ibb2fe558f98190f2a06da830e0fadfa25516f547