Commit Graph

27515 Commits

Author SHA1 Message Date
George Joseph be811c4be1 res_pjsip_caller_id: Fix segfault when replacing rpid or pai header
If the PJSIP_HEADER dialplan function adds a PAI or RPID header and send_rpid
or send_pai is set, res_pjsip_caller_id attemps to retrieve, parse and modify
the header added by the dialplan function.  Since the header added by the
dialplan function is generic string, there are no virtual functions to parse
the uri and we get a segfault when we try.  Since the modify, was really only
an overwrite, we now just delete the old header if it was type PJSIP_H_OTHER
and recreate it.

This raises a question for another time though:  What should happen with
duplicate headers?  Right now res_pjsip_header_funcs doesn't check for dups
so if it's session supplement is loaded after res_pjsip_caller_id's (or any
other module that adds headers), there'll be dups in the message.

ASTERISK-25337 #close

Change-Id: I5e296b52d30f106b822c0eb27c4c2b0e0f71c7fa
2016-02-15 15:53:32 -06:00
zuul 23b2b7747d Merge "Fix creation race of contact_status structures." 2016-02-15 15:39:47 -06:00
Mark Michelson 13b6c02945 Fix creation race of contact_status structures.
It is possible when processing a SIP REGISTER request to have two
threads end up creating contact_status structures in sorcery.
contact_status is created using a "find or create" function. If two
threads call into this at the same time, each thread will fail to find
an existing contact_status, and so both will end up creating a new
contact status.

During testing, we would see sporadic failures because the
PJSIP_CONTACT() dialplan function would operate on a different
contact_status than what had been updated by res_pjsip/pjsip_options.

The fix here is two-fold:
1) The "find or create" function for contact_status now has a lock
around the entire operation. This way, if two threads attempt the
operation simultaneously, the first to get there will create the object,
and the second will find the object created by the first thread.

2) res_sorcery_memory has had its create callback updated so that it
will not allow for objects with duplicate IDs to be created.

Change-Id: I55b1460ff1eb0af0a3697b82d7c2bac9f6af5b97
2016-02-15 13:48:44 -06:00
Joshua Colp 5c400a0fed res_pjsip_pubsub: Move where the subscription is stored to after initialized.
A problem arose when testing the AMI subscription listing actions where it
was possible for a subscription that had not been fully initialized to be
listed. This was problematic as the underlying listing code would crash.

This change makes it so the subscription tree is fully set up before it is
added to the list of subscriptions. This ensures that when the listing actions
get the subscription it is valid.

ASTERISK-25738 #close

Change-Id: Iace2b13641c31bbcc0d43a39f99aba1f340c0f48
2016-02-15 13:01:54 -06:00
zuul 1783edd181 Merge "res_pjsip: Refactor load_module/unload_module" 2016-02-12 16:50:18 -06:00
zuul 295a501d79 Merge "res_pjsip: Handle pjsip_dlg_create_uas deprecation" 2016-02-12 16:50:13 -06:00
George Joseph b37555cc94 res_pjsip: Refactor load_module/unload_module
load_module was just too hairy with every step having to clean up all
previous steps on failure.

Some of the pjproject init calls have now been moved to a separate
load_pjsip function and the unload_pjsip function was enhanced to clean
up everything if an error happened at any stage of the load process.

In the process, a bunch of missing pj_shutdowns, serializer_pool_shutdowns
and ast_threadpool_shutdowns were also corrected.

Change-Id: I5eec711b437c35b56605ed99537ebbb30463b302
2016-02-11 19:05:11 -07:00
zuul a39486552e Merge "Resources/res_phoneprov: fix memory leak and heap-use-after-free" 2016-02-11 17:04:51 -06:00
Badalyan Vyacheslav c4d9f46878 Resources/res_phoneprov: fix memory leak and heap-use-after-free
* heap-use-after-free happens when we free "cfg"
but then use "value" which refers to it

* A memory leak occurs because in some cases
it is not released "defaults"

ASTERISK-25721 #close
Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav

Change-Id: I3807d3f4726df6864430ec144cf6265d3f538469
2016-02-11 20:19:03 +00:00
Sean Bright e5fd972d24 func_iconv: Ensure output strings are properly terminated.
ASTERISK-25272 #close
Reported by: Etienne Lessard
patches:
 AST-25272.patch submitted by Etienne Lessard (license #6394)

Change-Id: Id75ad202300960a1e91afe15e319d992936ecc17
2016-02-11 11:26:03 -06:00
Joshua Colp 39a6cd8a79 Merge "res_pjsip: Fix infinite recursion when loading transports from realtime" 2016-02-11 06:10:06 -06:00
George Joseph 168c18737f res_pjsip: Handle pjsip_dlg_create_uas deprecation
Pjproject has deprecated pjsip_dlg_create_uas in 2.5 and replaced it with
pjsip_dlg_create_uas_and_inc_lock which, as the name implies, automatically
increments the lock on the returned dialog.  To account for this, configure.ac
now detects the presence of pjsip_dlg_create_uas_and_inc_lock and res_pjsip.c
has an #ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK to decide whether to use
the original call or the new one.  If the new one was used, the ref count is
decremented before returning.

ASTERISK-25751 #close
Reported-by Josh Colp

Change-Id: I1be776b94761df03bd0693bc7795a75682615ca8
2016-02-10 15:28:08 -07:00
Mark Michelson 22bef60b1a Merge "res_config_pgsql: Show error message in reload if not connected." 2016-02-10 15:35:01 -06:00
Joshua Colp 3b3d64234e Merge "Build: Fix menuselect USAN conflicts" 2016-02-10 14:34:51 -06:00
Rodrigo Ramírez Norambuena fd668670b5 res_config_pgsql: Show error message in reload if not connected.
Change-Id: I9290115a1aaadb589eb1d02eaeb502eec01b31fa
2016-02-10 14:41:09 -03:00
Badalyan Vyacheslav a23d01e943 Build: Added testing compiler to support the system sanitizes
In older versions of the compiler was not sanitizes.
Compilers other than GCC can not support the Usan and TSAN
or have other options for *FLAGS.

ASTERISK-25767 #close
Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav

Change-Id: Iefce6608221fa87884b82ae3cb5649b7b1804916
2016-02-10 05:40:32 +00:00
Badalyan Vyacheslav c7186c7f0a Build: Fix menuselect USAN conflicts
USAN can be used together with other sanitizers.

Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav

Change-Id: I3bffa350d70965c3026651dba3a12414d0aaa45f
2016-02-09 22:13:09 -06:00
Corey Farrell 68643f83cd Simplify and fix conditional in FD_SET.
FD_SET contains a conditional statement to protect against buffer
overruns.  The statement was overly complicated and prevented use
of the last array element of ast_fdset.  We now just verify the fd
is less than ast_FDMAX.

Change-Id: I41895c0b497b052aef5bf49d75c817c48b326f40
2016-02-09 14:39:35 -06:00
Joshua Colp cf89aecc8a Merge "res_config_pgsql: Add message on cli failed command status" 2016-02-09 13:45:33 -06:00
Joshua Colp e40fddbeb5 tests/test_sorcery_memory_cache_thrash: Improve termination process.
When terminating the threads thrashing a sorcery memory cache each
would be told to stop and then we would wait on them. During at
least one thrashing test this was problematic due to the specific
usage pattern in use. It would take some time for termination of the
thread to occur.

This would occur due to contention between the threads retrieving
and the threads updating the cache. As the retrieving threads are
given priority it may be some time before the updating threads
are able to proceed.

This change makes it so all threads are told to stop and then each
are joined to ensure they stop. This way all the threads should
stop at around the same time instead of waiting for one to stop,
the next to stop, then the next, and so on. As a result of this
the execution time for each thrash test is much closer to their
expected value than previously seen as well.

Change-Id: I04a53470b0ea4170b8819180b0bd7475f3642827
2016-02-09 11:25:01 -06:00
George Joseph bbf3ace682 res_pjsip: Fix infinite recursion when loading transports from realtime
Attempting to load a transport from realtime was forcing asterisk into an
infinite recursion loop.  The first thing transport_apply did was to do a
sorcery retrieve by id for an existing transport of the same name. For files,
this just returns the previous object from res_sorcery_config's internal
container, if any.  For realtime, the res_sourcery_realtime driver looks in the
database and finds the existing row but now it has to rehydrate it into a
sorcery object which means calling... transport_apply.  And so it goes.

The main issue with loading from realtime (apart from the loop) was that
transport stores structures and pointers directly in the ast_sip_transport
structure instead of the separate ast_transport_state structure.  This patch
separates those items into the ast_sip_transport_state structure.  The pattern
is roughly the same as res_pjsip_outbound_registration.

Although all current usages of ast_sip_transport and ast_sip_transport_state
were modified to use the new ast_sip_get_transport_state API, the original
items are left in ast_sip_transport and kept updated to maintain ABI
compatability for third-party modules.  They are marked as deprecated and
noted that they're now in ast_sip_transport_state.

ASTERISK-25606 #close
Reported-by: Martin Moučka

Change-Id: Ic7a836ea8e786e8def51fe3f8cce855ea54f5f19
2016-02-08 19:11:18 -06:00
Joshua Colp 7e4378770d Merge "chan_misdn: Fix a few issues causing compile errors" 2016-02-08 05:56:52 -06:00
Rodrigo Ramírez Norambuena 72bf53eea5 res_config_pgsql: Add message on cli failed command status
In case failed of command "realtime show pgsql status" show a message the data
of connection to more clear information in error.

Change-Id: Ia8e9e2400466606e7118f52a46e05df0719b6a29
2016-02-07 17:08:43 -03:00
George Joseph b69729dde5 chan_misdn: Fix a few issues causing compile errors
Change-Id: I54b48c24d7ca88ed80496fdfd142d08772a7ab98
2016-02-05 11:58:54 -06:00
Richard Mudgett 1bc54aee80 app_confbridge: Only use b_profile options from the conference.
A user cannot set new bridge options after the conference is created by
the first user.  Attempting to do so is documented as undefined behavior.

This patch ensures that the bridge profile options used are from the
conference and not what a subsequent user may have tried to set.

Change-Id: I1b6383eba654679e5739d5a8de98199cf074a266
2016-02-05 11:57:48 -06:00
Joshua Colp fc0527eb4f Merge "pjsip/alembic: Add missing columns to system and registration" 2016-02-05 11:50:35 -06:00
Joshua Colp 0aea293450 Merge "app_confbridge.c: Replace inlined code with existing function." 2016-02-05 11:49:43 -06:00
Joshua Colp e541d9cf34 Merge topic 'ASTERISK-20987'
* changes:
  app_confbridge: Add ability to get the muted conference state.
  app_confbridge.c: Update CONFBRIDGE and CONFBRIDGE_INFO documentation.
  app_confbridge: Make non-admin users join a muted conference muted.
2016-02-05 11:49:15 -06:00
Mark Michelson 3b426a8b09 Check for OpenSSL defines before trying to use them.
The SSL_OP_NO_TLSv1_1 and SSL_OP_NO_TLSv1_2 defines did not exist prior
to OpenSSL version 1.0.1. A recent commit attempts to, by default, set
these options, which can cause problems on systems with older OpenSSL
installations.

This commit adds a configure script check for those defines and will not
attempt to make use of those if they do not exist. We will print a
warning urging the user to upgrade their OpenSSL installation if those
defines are not present.

Change-Id: I6a2eb9a43fd0738b404d8f6f2cf4b5c22d9d752d
2016-02-04 16:57:46 -06:00
George Joseph 9b13ab6a63 pjsip/alembic: Add missing columns to system and registration
ps_systems needed disable_tcp_switch
ps_registrations needed line and endpoint

ASTERISK-25737 #close

Change-Id: Iaf9c2d69e62243d9fa53104c28c5339c47d4ac19
2016-02-04 14:23:45 -06:00
Mark Michelson c0a8ecc8c0 Merge "logging: Remove/fix some message annoyances" 2016-02-04 14:10:58 -06:00
Joshua Colp d8f1a74d15 Merge "res_stasis_device_state: Fix refcounting error." 2016-02-04 12:35:37 -06:00
Joshua Colp 299278c45b Merge "app_queue: Add Lastpause field of queue member" 2016-02-04 12:29:18 -06:00
Joshua Colp 8b311bebd8 Merge "res_xmpp: Does not connect in component mode" 2016-02-04 12:26:49 -06:00
Mark Michelson 82e2938fa8 res_stasis_device_state: Fix refcounting error.
Device state subscription lifetimes were governed by when the
subscription was established and unsubscribed from. However, it is
possible that at the time of unsubscription, there could be device state
events still in flight. When those device state events occur, the device
state callback could attempt to dereference a freed pointer. Crash.

This change ensures that the lifetime of the device state subscription
does not end until the underlying stasis subscription has confirmed that
its final message has been sent.

Change-Id: I25a0f1472894c1a562252fb7129671478e25e9b2
2016-02-04 12:05:52 -06:00
Sean Bright d83dba7099 res_rtp_asterisk: Allow ICE host candidates to be overriden
During ICE negotiation the IPs of the local interfaces are sent to the remote
peer as host candidates. In many cases Asterisk is behind a static one-to-one
NAT, so these host addresses will be internal IP addresses.

To help in hiding the topology of the internal network, this patch adds the
ability to override the host candidates by matching them against a
user-defined list of replacements.

Change-Id: I1c9541af97b83a4c690c8150d19bf7202c8bff1f
2016-02-03 17:06:20 -06:00
Kevin Harwell e89114c1be Merge "AST-2016-003 udptl.c: Fix uninitialized values." 2016-02-03 15:17:22 -06:00
Kevin Harwell 0389555c12 Merge "AST-2016-002 chan_sip.c: Fix retransmission timeout integer overflow." 2016-02-03 15:14:53 -06:00
Joshua Colp 0de74fad55 AST-2016-001 http: Provide greater control of TLS and set modern defaults.
This change exposes the configuration of various aspects of the TLS
support and sets the default to the modern standards.

The TLS cipher is now set to the best values according to the
Mozilla OpSec team, different TLS versions can now be disabled, and
the cipher order can be forced to be that of the server instead of
the client.

ASTERISK-24972 #close

Change-Id: I0a10f2883f7559af5e48dee0901251dbf30d45b8
2016-02-03 15:10:16 -06:00
Richard Mudgett e67b445e8d AST-2016-003 udptl.c: Fix uninitialized values.
Sending UDPTL packets to Asterisk with the right amount of missing
sequence numbers and enough redundant 0-length IFP packets, can make
Asterisk crash.

ASTERISK-25603 #close
Reported by: Walter Doekes

ASTERISK-25742 #close
Reported by: Torrey Searle

Change-Id: I97df8375041be986f3f266ac1946a538023a5255
2016-02-03 15:07:04 -06:00
Richard Mudgett a877e0d94b AST-2016-002 chan_sip.c: Fix retransmission timeout integer overflow.
Setting the sip.conf timert1 value to a value higher than 1245 can cause
an integer overflow and result in large retransmit timeout times.  These
large timeout times hold system file descriptors hostage and can cause the
system to run out of file descriptors.

NOTE: The default sip.conf timert1 value is 500 which does not expose the
vulnerability.

* The overflow is now detected and the previous timeout time is
calculated.

ASTERISK-25397 #close
Reported by: Alexander Traud

Change-Id: Ia7231f2f415af1cbf90b923e001b9219cff46290
2016-02-03 15:04:08 -06:00
George Joseph dcbedf9ab1 logging: Remove/fix some message annoyances
test_dlinklists doesn't need to NOTICE everyone that every macro worked.

res_phoneprov doesn't need to VERBOSE everyone that a phoneprov extension or
provider was registered.

res_odbc was missing a newline at the end of one message.

Change-Id: I6c06361518ef3711821795e535acd439782a995e
2016-02-03 14:11:11 -06:00
Joshua Colp ae1f728f0f Merge "res_sorcery_realtime: Fix regex regression." 2016-02-03 10:14:45 -06:00
Joshua Colp 4b768281bb Merge "cdr_pgsql.cl: REFACTOR Macro LENGTHEN_BUF" 2016-02-03 06:20:18 -06:00
Joshua Colp ef293354dc Merge "app_queue: fix some tab format" 2016-02-03 06:19:48 -06:00
Joshua Colp 90e1439296 Merge "README: Update year in copyright" 2016-02-03 06:19:29 -06:00
Joshua Colp fe059b3534 Merge "app_queue: Fix preserved reason of pause when Asterisk is restared" 2016-02-03 06:19:19 -06:00
Joshua Colp 527057ae24 Merge "app_queue.c: remove include for core_unreal.h not used in code." 2016-02-03 06:18:58 -06:00
Mark Michelson d89f0b09de Merge "chan_sip.c: AMI & CLI notify methods get different values of asterisk's own ip." 2016-02-02 15:58:50 -06:00
Mark Michelson 6522361871 res_sorcery_realtime: Fix regex regression.
A regression was introduced where searching for realtime PJSIP objects
by regex by starting the regex with a leading "^" would cause no items
to be returned.

This was due to a change which attempted to drop the requirement for a
leading "^" to be present due to how some CLI commands formulate their
regexes. However, the change, rather than simply eliminating the
requirement, caused any regexes that did begin with "^" to end up not
returning the expected results.

This change fixes the problem by inspecting the regex and formulating
the realtime query differently depending on if it begins with "^".

ASTERISK-25702 #close
Reported by Nic Colledge

Patches:
    realtime_retrieve_regex.patch submitted by Alexei Gradinari License #5691

Change-Id: I055df608a6e6a10732044fa737a9fe8dca602693
2016-02-02 15:01:37 -06:00