]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
10 years agoMakefile: Remove coverage files on 'make clean' 77/777/1
Matt Jordan [Sat, 27 Jun 2015 23:47:19 +0000 (18:47 -0500)] 
Makefile: Remove coverage files on 'make clean'

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

10 years agoMerge "chan_vpb.cc: Fix compiler warning Jenkins found." into 13
Joshua Colp [Thu, 2 Jul 2015 14:47:48 +0000 (09:47 -0500)] 
Merge "chan_vpb.cc: Fix compiler warning Jenkins found." into 13

10 years agoMerge "sorcery/realtime: Add a bit of debug and warning messages for bad configs...
Matt Jordan [Thu, 2 Jul 2015 13:02:00 +0000 (08:02 -0500)] 
Merge "sorcery/realtime: Add a bit of debug and warning messages for bad configs" into 13

10 years agoMerge "res_timing: Don't close FD 0 when out of open files." into 13
Joshua Colp [Thu, 2 Jul 2015 12:53:35 +0000 (07:53 -0500)] 
Merge "res_timing: Don't close FD 0 when out of open files." into 13

10 years agoMerge "rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format....
Joshua Colp [Thu, 2 Jul 2015 12:52:29 +0000 (07:52 -0500)] 
Merge "rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format." into 13

10 years agoMerge "astfd: Fix buffer overflow in DEBUG_FD_LEAKS." into 13
Joshua Colp [Thu, 2 Jul 2015 12:51:43 +0000 (07:51 -0500)] 
Merge "astfd: Fix buffer overflow in DEBUG_FD_LEAKS." into 13

10 years agoMerge "chan_mgcp: Don't call close on fd -1." into 13
Joshua Colp [Thu, 2 Jul 2015 12:50:40 +0000 (07:50 -0500)] 
Merge "chan_mgcp: Don't call close on fd -1." into 13

10 years agochan_mgcp: Don't call close on fd -1. 69/769/1
Walter Doekes [Thu, 2 Jul 2015 11:19:34 +0000 (13:19 +0200)] 
chan_mgcp: Don't call close on fd -1.

ASTERISK-25220 #close

Change-Id: Ic48f3a82f51ada87f2fb0e016c9efe0ad56f1ee3

10 years agortp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format. 66/766/1
Walter Doekes [Thu, 2 Jul 2015 11:10:59 +0000 (13:10 +0200)] 
rtp_engine: Skip useless self-assignment in ast_rtp_engine_unload_format.

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

10 years agoastfd: Fix buffer overflow in DEBUG_FD_LEAKS. 63/763/1
Walter Doekes [Thu, 2 Jul 2015 10:16:26 +0000 (12:16 +0200)] 
astfd: Fix buffer overflow in DEBUG_FD_LEAKS.

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

10 years agores_timing: Don't close FD 0 when out of open files. 60/760/1
Walter Doekes [Thu, 2 Jul 2015 09:57:44 +0000 (11:57 +0200)] 
res_timing: Don't close FD 0 when out of open files.

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 13 branch, this was already fixed. This patch only ensures that
we do not attempt to close a negative file descriptor.

Change-Id: I147d7e33726c6e5a2751928d56561494f5800350

10 years agochan_vpb.cc: Fix compiler warning Jenkins found. 57/757/1
Richard Mudgett [Wed, 1 Jul 2015 22:25:31 +0000 (17:25 -0500)] 
chan_vpb.cc: Fix compiler warning Jenkins found.

Change-Id: I0ec7fd10d56d90d5a60b12b5a7d6807f265ac5e0

10 years agoChannel alert pipe: improve diagnostic error return 54/754/1
Scott Griepentrog [Wed, 1 Jul 2015 18:34:46 +0000 (13:34 -0500)] 
Channel alert pipe: improve diagnostic error return

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

10 years agosorcery/realtime: Add a bit of debug and warning messages for bad configs 53/753/2
Matt Jordan [Wed, 1 Jul 2015 21:04:50 +0000 (16:04 -0500)] 
sorcery/realtime: Add a bit of debug and warning messages for bad configs

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

10 years agoMerge "res_sorcery_realtime: Fix leak of sorcery object type." into 13
Joshua Colp [Tue, 30 Jun 2015 12:32:03 +0000 (07:32 -0500)] 
Merge "res_sorcery_realtime: Fix leak of sorcery object type." into 13

10 years agoMerge "channel: Remove ignore of answer on non-outgoing channels." into 13
Matt Jordan [Tue, 30 Jun 2015 12:07:13 +0000 (07:07 -0500)] 
Merge "channel: Remove ignore of answer on non-outgoing channels." into 13

10 years agores_sorcery_realtime: Fix leak of sorcery object type. 45/745/2
Mark Michelson [Mon, 29 Jun 2015 17:45:02 +0000 (12:45 -0500)] 
res_sorcery_realtime: Fix leak of sorcery object type.

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

10 years agoMerge "res_pjsip_nat: Adjust when contact should be rewritten." into 13
Matt Jordan [Mon, 29 Jun 2015 16:57:00 +0000 (11:57 -0500)] 
Merge "res_pjsip_nat: Adjust when contact should be rewritten." into 13

10 years agoMerge "res/res_corosync: Always decline module load, instead of failing" into 13
Matt Jordan [Mon, 29 Jun 2015 16:16:01 +0000 (11:16 -0500)] 
Merge "res/res_corosync: Always decline module load, instead of failing" into 13

10 years agores/res_corosync: Always decline module load, instead of failing 41/741/1
Matt Jordan [Sat, 27 Jun 2015 03:02:42 +0000 (22:02 -0500)] 
res/res_corosync: Always decline module load, instead of failing

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

10 years agomain/pbx: Resolve case sensitivity regression in PBX hints 39/739/1
Matt Jordan [Sat, 27 Jun 2015 01:38:58 +0000 (20:38 -0500)] 
main/pbx: Resolve case sensitivity regression in PBX hints

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 96bbcf495a1da9e607d9b04a44b5c4f49e83cc03)

10 years agores_pjsip_nat: Adjust when contact should be rewritten. 36/736/1
Mark Michelson [Fri, 26 Jun 2015 21:12:33 +0000 (16:12 -0500)] 
res_pjsip_nat: Adjust when contact should be rewritten.

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

10 years agores_pjsip_outbound_registration.c: Add a serializer shutdown group. 91/691/4
Richard Mudgett [Fri, 19 Jun 2015 23:27:24 +0000 (18:27 -0500)] 
res_pjsip_outbound_registration.c: Add a serializer shutdown group.

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

10 years agoMerge "threadpool, res_pjsip: Add serializer group shutdown API calls." into 13
Matt Jordan [Fri, 26 Jun 2015 18:35:07 +0000 (13:35 -0500)] 
Merge "threadpool, res_pjsip: Add serializer group shutdown API calls." into 13

10 years agoMerge "res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs...
Matt Jordan [Fri, 26 Jun 2015 18:35:01 +0000 (13:35 -0500)] 
Merge "res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs" into 13

10 years agoMerge "res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API...
Matt Jordan [Fri, 26 Jun 2015 18:34:38 +0000 (13:34 -0500)] 
Merge "res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API" into 13

10 years agoMerge "res_pjsip_refer: Prevent sending duplicate headers." into 13
Matt Jordan [Fri, 26 Jun 2015 16:27:00 +0000 (11:27 -0500)] 
Merge "res_pjsip_refer: Prevent sending duplicate headers." into 13

10 years agoMerge "sorcery: Add ast_sorcery_object_unregister() API call." into 13
Matt Jordan [Fri, 26 Jun 2015 16:26:06 +0000 (11:26 -0500)] 
Merge "sorcery: Add ast_sorcery_object_unregister() API call." into 13

10 years agoMerge "res_pjsip_outbound_registration.c: Reorder load_module() and unload_module...
Matt Jordan [Fri, 26 Jun 2015 16:25:38 +0000 (11:25 -0500)] 
Merge "res_pjsip_outbound_registration.c: Reorder load_module() and unload_module()." into 13

10 years agores_pjsip_refer: Prevent sending duplicate headers. 30/730/1
Mark Michelson [Fri, 26 Jun 2015 15:41:05 +0000 (10:41 -0500)] 
res_pjsip_refer: Prevent sending duplicate headers.

res_pjsip_refer will attempt to add Referred-By or Replaces headers to
outbound INVITEs at times. If the INVITE gets challenged for
authentication, then we will resend the INVITE. Prior to this patch, the
Referred-By or Replaces header would be re-added to the outbound INVITE,
resulting in duplicated headers.

ASTERISK-25204 #close
Reported by Mark Michelson

Change-Id: I59fb5c08b4d253c0dba9ee3d3950b5025358222d

10 years agoMerge "AMI: Add Linkedid to the standard channel snapshot AMI event headers." into 13
Matt Jordan [Fri, 26 Jun 2015 15:59:04 +0000 (10:59 -0500)] 
Merge "AMI: Add Linkedid to the standard channel snapshot AMI event headers." into 13

10 years agores_pjsip_nat: Rewrite route set when required. 23/723/2
Mark Michelson [Tue, 23 Jun 2015 22:43:31 +0000 (17:43 -0500)] 
res_pjsip_nat: Rewrite route set when required.

When performing some provider testing, the rewrite_contact option was
interfering with proper construction of a route set when sending an ACK
after receiving a 200 OK response to an INVITE.

The initial INVITE was sent to address sip:foo. The 200 OK had a Contact
header with URI sip:bar. In addition, the 200 OK had Record-Route
headers for sip:baz and sip:foo, in that order. Since the Record-Route
headers had the lr parameter, the result should have been:

* Set R-URI of the ACK to sip:bar.
* Add Route headers for sip:foo and sip:baz, in that order.

However, the rewrite_contact option resulted in our rewriting the
Contact header on the 200 OK to sip:foo. The result was:

* R-URI remained sip:foo.
* We added Route headers for sip:foo and sip:baz, in that order.

The result was that sip:bar was not indicated in the ACK at all, so the
far end never received our ACK. The call eventually dropped.

The intention of rewrite_contact is to rewrite the most immediate
destination of our SIP request to be the same address on which we
received a request or response. In the case of processing a SIP response
with Record-Route headers, this means that instead of rewriting the
Contact header, we should instead rewrite the bottom-most Record-Route
header. In the case of processing a SIP request with Record-Route
headers, this means we rewrite the top-most Record-route header.
Like when we rewrite the Contact header, we also ensure to update
the dialog's route set if it exists.

ASTERISK-25196 #close
Reported by Mark Michelson

Change-Id: I9702157c3603a2d0bd8a8215ac27564d366b666f

10 years agothreadpool, res_pjsip: Add serializer group shutdown API calls. 90/690/3
Richard Mudgett [Fri, 19 Jun 2015 21:16:17 +0000 (16:16 -0500)] 
threadpool, res_pjsip: Add serializer group shutdown API calls.

A module trying to unload needs to wait for all serializers it creates and
uses to complete processing before unloading.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I8c80b90f2f82754e8dbb02ddf3c9121e5e966059

10 years agores_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs 89/689/3
Richard Mudgett [Tue, 16 Jun 2015 20:06:22 +0000 (15:06 -0500)] 
res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs

* handle_client_state_destruction() must always be passed a ref to
client_state because it will always unref client_state.
handle_registration_response() was not passing a client_state ref.

* Made the final un-REGISTER message get sent normally using the pjproject
register control structure in handle_client_state_destruction().  The
previous code attempted to short circuit the response handling for the
module to unload.  That doesn't work for a couple reasons.  One,
pjsip_regc_send() may call the registered callback before it returns and
unbalance the client_state ref count.  Two, the registered callback
handles any authentication for the un-REGISTER message.

* Made the distinction between internal registration state and external
registration status with sip_outbound_registration_status_str().  This is
necessary to avoid altering documented AMI messages with internal
changes.

* Removed references to client_state->client outside of the serializer
thread.  When handle_client_state_destruction() destroys the pjproject
register control structure that memory is freed and cannot be referenced
anymore.  These accesses were to provide information for debug and
off-nominal warning messages.

* In sip_outbound_registration_timer_cb() you should not access entry->id
after unrefing client_state because the passed in entry is normally
pointing to the timer entry in the client_state object.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: Ia7b446d8644b6b4550ef5bea49527671de65183f

10 years agores_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API 88/688/3
Richard Mudgett [Mon, 15 Jun 2015 20:28:41 +0000 (15:28 -0500)] 
res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API

The sorcery pjsip 'registration' config object needs to be destroyed on
module unload.  Otherwise, a reload of res_pjsip could try to use
callbacks for a previously unloaded instance of the module provided by
ast_sorcery_object_register() or one of the variants.  Also, if
res_pjsip_outbound_registration were subsequently reloaded, the sorcery
config field objects would be registered in sorcery twice.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I304fad13dece2604af48353f6c6d9d5c7b064697

10 years agochannel: Remove ignore of answer on non-outgoing channels. 25/725/1
Joshua Colp [Thu, 25 Jun 2015 11:42:46 +0000 (08:42 -0300)] 
channel: Remove ignore of answer on non-outgoing channels.

Due to the way that channels can now be moved around inside of
Asterisk it is possible for the outgoing flag of a channel to get
cleared before it has been answered. This results in the bridge
not receiving notification that the outgoing leg has been answered.

This most easily exhibits itself with DTMF based blond transfers.
Since the answer of the outgoing leg is ignored the other party
continues to receive both a locally generated ringing and the
media stream of the outgoing leg upon its answer. This results
in no media being heard.

This change removes the ignore of the answer and allows it
to pass through.

ASTERISK-25171 #close

Change-Id: I82aedcec4f89f34a2e5472086dfc9a6c775bca8e

10 years agosorcery: Add ast_sorcery_object_unregister() API call. 87/687/3
Richard Mudgett [Mon, 15 Jun 2015 20:28:00 +0000 (15:28 -0500)] 
sorcery: Add ast_sorcery_object_unregister() API call.

Find and unlink the specified sorcery object type to complement
ast_sorcery_object_register().  Without this function you cannot
completely unload individual modules that use sorcery for configuration.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I1c04634fe9a90921bf676725c7d6bb2aeaab1c88

10 years agores_pjsip_outbound_registration.c: Reorder load_module() and unload_module(). 86/686/3
Richard Mudgett [Mon, 15 Jun 2015 18:38:58 +0000 (13:38 -0500)] 
res_pjsip_outbound_registration.c: Reorder load_module() and unload_module().

It is best if the loading code creates and initializes the module's
infrastructure before letting the system know of its existence.  The
unloading code needs to reverse the actions of the loading code and in the
reverse order.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I5d151383e9787b5b60aa5e1627b10f040acdded4

10 years agoAMI: Add Linkedid to the standard channel snapshot AMI event headers. 00/700/2
Richard Mudgett [Tue, 23 Jun 2015 19:34:29 +0000 (14:34 -0500)] 
AMI: Add Linkedid to the standard channel snapshot AMI event headers.

* The AMI version is bumped to 2.8.0.

ASTERISK-25189 #close
Reported by: John Hardin

Change-Id: I2b1778c3fdc1dca0ed55db4e3a639eddfb16c2ac

10 years agoMerge "res_pjsip_mwi: Set up unsolicited MWI upon registration." into 13
Mark Michelson [Thu, 25 Jun 2015 14:52:04 +0000 (09:52 -0500)] 
Merge "res_pjsip_mwi: Set up unsolicited MWI upon registration." into 13

10 years agoMerge "test.c: Add unit test registration checks for summary and description." into 13
Joshua Colp [Thu, 25 Jun 2015 09:51:37 +0000 (04:51 -0500)] 
Merge "test.c: Add unit test registration checks for summary and description." into 13

10 years agoMerge "Unit tests: Fix unit test description strings." into 13
Joshua Colp [Thu, 25 Jun 2015 09:50:22 +0000 (04:50 -0500)] 
Merge "Unit tests: Fix unit test description strings." into 13

10 years agotest.c: Add unit test registration checks for summary and description. 15/715/1
Richard Mudgett [Wed, 24 Jun 2015 19:30:15 +0000 (14:30 -0500)] 
test.c: Add unit test registration checks for summary and description.

Added checks when a unit test is registered to see that the summary and
description strings do not end with a new-line '\n' for consistency.

The check generates a warning message and will cause the
/main/test/registrations unit test to fail.

* Updated struct ast_test_info member doxygen comments.

Change-Id: I295909b6bc013ed9b6882e85c05287082497534d

10 years agoUnit tests: Fix unit test description strings. 14/714/1
Richard Mudgett [Wed, 24 Jun 2015 19:39:01 +0000 (14:39 -0500)] 
Unit tests: Fix unit test description strings.

Analyzing the code shows that the unit test summary and description
strings should not end with a new-line character.  Where these strings are
used in the code a new-line is provided for output.

Change-Id: I129284f5e7ca93d82532334076da4c462d3d9fba

10 years agoMerge "app_dial: Hold reference to calling channel formats when dialing outbound...
Matt Jordan [Wed, 24 Jun 2015 22:07:00 +0000 (17:07 -0500)] 
Merge "app_dial: Hold reference to calling channel formats when dialing outbound." into 13

10 years agoapp_dial: Hold reference to calling channel formats when dialing outbound. 02/702/2
Joshua Colp [Tue, 23 Jun 2015 16:21:41 +0000 (13:21 -0300)] 
app_dial: Hold reference to calling channel formats when dialing outbound.

Currently when requesting a channel the native formats of the
calling channel are provided to the core for usage when dialing
the outbound channel. This occurs without holding the channel lock
or keeping a reference to the formats. This is problematic as
the channel driver may end up changing the formats during this time.
In the case of chan_sip this happens when an SDP negotiation
completes.

This change makes it so app_dial keeps a reference to the native
formats of the calling channel which guarantees that they will
remain valid for the period of time needed.

ASTERISK-25172 #close

Change-Id: I2f0a67bd0d5d14c3bdbaae552b4b1613a283f0db

10 years agoMerge "res_pjsip_outbound_registration.c: Add missing line endings to CLI commands...
Matt Jordan [Wed, 24 Jun 2015 13:38:52 +0000 (08:38 -0500)] 
Merge "res_pjsip_outbound_registration.c: Add missing line endings to CLI commands" into 13

10 years agoMerge "res_pjsip_outbound_registration.c: Eliminate simple RAII_VAR() usage." into 13
Matt Jordan [Wed, 24 Jun 2015 13:38:36 +0000 (08:38 -0500)] 
Merge "res_pjsip_outbound_registration.c: Eliminate simple RAII_VAR() usage." into 13

10 years agoMerge "res_pjsip_outbound_registration.c: Misc code cleanups." into 13
Matt Jordan [Wed, 24 Jun 2015 13:37:44 +0000 (08:37 -0500)] 
Merge "res_pjsip_outbound_registration.c: Misc code cleanups." into 13

10 years agoMerge "bridge.c: Hangup attended transfer target if bridged" into 13
Matt Jordan [Tue, 23 Jun 2015 16:36:34 +0000 (11:36 -0500)] 
Merge "bridge.c: Hangup attended transfer target if bridged" into 13

10 years agores_pjsip_mwi: Set up unsolicited MWI upon registration. 76/676/3
Joshua Colp [Wed, 17 Jun 2015 10:04:39 +0000 (07:04 -0300)] 
res_pjsip_mwi: Set up unsolicited MWI upon registration.

The res_pjsip_mwi previously required a reload to set up the proper
subscriptions to allow unsolicited MWI to work. This change
makes it so the act of registering will also cause this to occur.
This is particularly useful if realtime is involved as no reload
needs to occur within Asterisk to cause the MWI information
to get sent.

ASTERISK-25180 #close

Change-Id: Id847b47de4b8b3ab8858455ccc2f07b0f915f252

10 years agobridge.c: Hangup attended transfer target if bridged 92/692/1
Kevin Harwell [Mon, 22 Jun 2015 20:11:18 +0000 (15:11 -0500)] 
bridge.c: Hangup attended transfer target if bridged

After completing an attended transfer the transfer target channel was not being
hung up after leaving the bridge. Added an explicit softhangup to hangup said
channel, but only if it was previously bridged.

ASTERISK-24782 #close
Reported by: John Bigelow

Change-Id: Idde9543d56842369384a5e8c00d72a22bbc39ada

10 years agores_pjsip_outbound_registration.c: Add missing line endings to CLI commands 85/685/1
Richard Mudgett [Wed, 17 Jun 2015 21:23:52 +0000 (16:23 -0500)] 
res_pjsip_outbound_registration.c: Add missing line endings to CLI commands

Change-Id: I39ae612746d892d2dbe86f3ff2d7027fa1da57f7

10 years agores_pjsip_outbound_registration.c: Eliminate simple RAII_VAR() usage. 84/684/1
Richard Mudgett [Fri, 12 Jun 2015 19:29:06 +0000 (14:29 -0500)] 
res_pjsip_outbound_registration.c: Eliminate simple RAII_VAR() usage.

Change-Id: I399cb9d61bbba706b48c98e0bf75e98984cd9a9e

10 years agores_pjsip_outbound_registration.c: Misc code cleanups. 83/683/1
Richard Mudgett [Fri, 12 Jun 2015 18:33:38 +0000 (13:33 -0500)] 
res_pjsip_outbound_registration.c: Misc code cleanups.

* Break some long lines.

* Fix doxygen comment.

Change-Id: I8f12ba6822f84d5e7bb575280270cd7e2fefb305

10 years agochan_sip: Reload peer without its old capabilities. 81/681/1
Alexander Traud [Mon, 22 Jun 2015 14:26:48 +0000 (16:26 +0200)] 
chan_sip: Reload peer without its old capabilities.

On reload, previously allowed codecs were not removed. Therefore, it was not
possible to remove codecs while Asterisk was running. Furthermore, newly added
codecs got appended behind the previous codecs. Therefore, it was not possible
to add a codec with a priority of #1. This change removes the old capabilities
before the current ones are added.

ASTERISK-25182 #close
Reported by: Alexander Traud
patches:
 asterisk_13_allow_codec_reload.patch uploaded by Alexander Traud (License 6520)

Change-Id: I62a06bcf15e08e8c54a35612195f97179ebe5802

10 years agochan_sip: Destroy peers without holding peers container lock. 73/673/1
Joshua Colp [Sun, 21 Jun 2015 00:38:02 +0000 (21:38 -0300)] 
chan_sip: Destroy peers without holding peers container lock.

Due to the use of stasis_unsubscribe_and_join in the peer destructor
it is possible for a deadlock to occur when an event callback is
occurring at the same time.

This happens because the peer may be destroyed while holding the
peers container lock. If this occurs the event callback will never
be able to acquire the container lock and the unsubscribe will
never complete.

This change makes it so the peers that have been removed from the
peers container are not destroyed with the container lock held.

ASTERISK-25163 #close

Change-Id: Ic6bf1d9da4310142a4d196c45ddefb99317d9a33

10 years agoResolve race conditions involving Stasis bridges. 71/671/2
Mark Michelson [Thu, 18 Jun 2015 18:16:29 +0000 (13:16 -0500)] 
Resolve race conditions involving Stasis bridges.

This resolves two observed race conditions.

First, a bit of background on what the Stasis application does:

1a Creates a stasis_app_control structure. This structure is linked into
   a global container and can be looked up using a channel's unique ID.
2a Puts the channel in an event loop. The event loop can exit either
   because the stasis_app_control structure has been marked done, or
   because of some other factor, such as a hangup. In the event loop, the
   stasis_app_control determines if any specific ARI commands need to be
   run on the channel and will run them from this thread.
3a Checks if the channel is bridged. If the channel is bridged, then
   ast_bridge_depart() is called since channels that are added to Stasis
   bridges are always imparted as departable.
4a Unlink the stasis_app_control from the container.

When an ARI command is received by Asterisk, the following occurs
1b A thread is spawned to handle the HTTP request
2b The stasis_app_control(s) that corresponds to the channel(s) in the
   request is/are retrieved. If the stasis_app_control cannot be
   retrieved, then it is assumed that the channel in question has exited
   the Stasis app or perhaps was never in Stasis in the first place.
3b A command is queued onto the stasis_app_control, and the channel's
   event loop thread is signaled to run the command.
4b While most ARI commands do nothing further, some, such as adding or
   removing channels from a bridge, will block until the command they
   issued has been completed by the channel's event loop.

The first race condition that is solved by this patch involves a crash
that can occur due to faulty detection of the channel's bridged status
in step 3a. What can happen is that in step 2a, the event loop may run
the ast_bridge_impart() function to asynchronously place the channel
into a bridge, then immediately exit the event loop because the channel
has hung up. In step 3a, we would detect that the channel was not
bridged and would not call ast_bridge_depart(). The reason that the
channel did not appear to be bridged was that the depart_thread that is
spawned by ast_bridge_impart() had not yet started. That is the thread
where the channel is marked as being bridged. Since we did not call
ast_bridge_depart(), the Stasis application would exit, and then the
channel would be destroyed Then the depart_thread would start up and
try to manipulate the destroyed channel, causing a crash.

The fix for this is to switch from using ast_channel_is_bridged() to
checking the NULLity of ast_channel_internal_bridge_channel() to
determine if ast_bridge_depart() needs to be called. The channel's
internal bridge_channel is set when ast_bridge_impart() is called and
is NULLed by the call to ast_bridge_depart(). If the channel's internal
bridge_channel is non-NULL, then the channel must have been imparted
into the bridge and needs to be departed, even if the actual bridging
operation has not yet started. By departing the channel when necessary,
the thread that is running the Stasis application will block until the
bridge gives the okay that the depart_thread has exited.

The second race condition that is solved by this patch involves a leak
of HTTP handler threads. The problem was that step 2b would successfully
retrieve a stasis_app_control structure. Then step 2a would exit the
channel from the event loop due to a hangup. Steps 3a and 4a would
execute, and then finally steps 3b and 4b would. The problem is that at
step 4b, when attempting to add a channel to a bridge, the thread would
block forever since the channel would never execute the queued command
since it was finished with the event loop. This meant that the HTTP
handling thread would be leaked, along with any references that thread
may have owned (in my case, I was seeing bridges leaked).

The fix for this is to hone in better on when the channel has exited the
event loop. The stasis_app_control structure has an is_done field that
is now set at each point where the channel may exit the event loop. If
step 2b retrieves a valid stasis_app_control structure but the control
is marked as done, then the attempted operation exits immediately since
there will be nothing to service the attempted command.

ASTERISK-25091 #close
Reported by Ilya Trikoz

Change-Id: If66265b73b4c9f8f58599124d777fedc54576628

10 years agoParking: Add documentation for AMI ParkedCallSwap event. 66/666/2
Mark Michelson [Tue, 16 Jun 2015 16:13:20 +0000 (11:13 -0500)] 
Parking: Add documentation for AMI ParkedCallSwap event.

This event was added some time ago in order to clarify when a channel
took the place of another channel in a parking lot. However, there was
no XML documentation added for the event. This patch adds the XML
documentation.

ASTERISK-24900 #close
Reported by Rusty Newton

Change-Id: I4cfe7777c4b94bbff91c9221c6096a7a02a92eac

10 years agoMerge "res_pjsip: Add option to force G.726 to be treated as AAL2 packed." into 13
Joshua Colp [Tue, 16 Jun 2015 12:51:12 +0000 (07:51 -0500)] 
Merge "res_pjsip: Add option to force G.726 to be treated as AAL2 packed." into 13

10 years agofunc_pjsip_aor: Fix leaked contact from iterator. 61/661/1
Corey Farrell [Mon, 15 Jun 2015 21:40:54 +0000 (17:40 -0400)] 
func_pjsip_aor: Fix leaked contact from iterator.

ASTERISK-25162 #close

Change-Id: Id79aa3c6fe490016ee98efc97ac4c1d3f461f97e

10 years agores_pjsip: Add option to force G.726 to be treated as AAL2 packed. 51/651/2
Kevin Harwell [Fri, 12 Jun 2015 21:58:27 +0000 (16:58 -0500)] 
res_pjsip: Add option to force G.726 to be treated as AAL2 packed.

Some phones send g.726 audio packed for AAL2, which differs from what is
recommended by RFC 3351. If Asterisk receives audio formatted as such when
negotiating g.726 then it sounds a bit distorted. Added an option to
res_pjsip_endpoint that allows g.726 negotiated audio to be treated as g.726
AAL2 packed.

ASTERISK-25158 #close
Reported by: Steve Pitts

Change-Id: Ie7e21f75493d7fe53e75e12c971e72f5afa33615

10 years agomain/cdr: Carry over the disable flag when 'disable all' is specified 57/657/2
mjordan [Mon, 15 Jun 2015 00:48:26 +0000 (19:48 -0500)] 
main/cdr: Carry over the disable flag when 'disable all' is specified

The CDR_PROP function (as well as the NoCDR application) set the
'disable all' flag (AST_CDR_FLAG_DISABLE_ALL) on the current CDR. This
flag is supposed to be applied to all CDRs that are currently in the
chain, as well as all CDRs that may be created in the future. Currently,
however, the flag is only applied to the existing CDRs in the chain; new
CDRs do not receive the 'disable all' flag. In particular, this affects
parallel dials, which generate new CDRs for each pair of channels in
the dial attempt.

This patch carries over the 'disable all' flag when it is specified on a
CDR and a new CDR is generated for the chain.

ASTERISK-24344 #close

Change-Id: I91a0f0031e4d147bdf8a68ecd08304d506fb6a0e

10 years agomain/cdr: Copy context/exten on chained CDRs for parallel dials in subroutines 52/652/1
Matt Jordan [Fri, 12 Jun 2015 19:28:47 +0000 (14:28 -0500)] 
main/cdr: Copy context/exten on chained CDRs for parallel dials in subroutines

When a parallel dial occurs, a new CDR will be created for each dial
attempt that is made. In most circumstances, the act of creating each
CDR in the chain will include a step that updates the Party A snapshot,
which causes the context/extension of the Party A to be copied onto the
CDR object.

However, when the Party A is in a subroutine, we explicitly do *not*
copy the context/extension onto the CDR. This prevents the Macro or
GoSub routine name from blowing away the context/extension that the
channel was originally executing in. For the original CDR, this is not a
problem: the original CDR already recorded the last known 'good' state
of the channel just prior to it going into the subroutine. However, for
newly generated CDRs in a chain, there is no context/extension set on
them. Since we are in a subroutine, we will never set the Party A's
context/extension on the CDR, and we end up with a CDR with no
destination recorded on it.

This patch updates the creation of a chained CDR such that it copies
over the original CDR's context/extension. This is the last known "good"
state of the CDR, and is a reasonable starting point for the newly
generated CDR. In the case where we are not in a subroutine, subsequent
code will update the location of the CDR from the Party A information;
in the case where we are in a subroutine, the context/extension on the
original CDR is the correct information.

ASTERISK-24443 #close

Change-Id: I6a3ef0d6e458d3b9b30572feaec70f2964f3bc2a

10 years agoMerge "bridge: When performing a blonde transfer update connected line information...
Matt Jordan [Sat, 13 Jun 2015 13:36:41 +0000 (08:36 -0500)] 
Merge "bridge: When performing a blonde transfer update connected line information." into 13

10 years agoMerge "chan_sip.c: Update dialog fromtag after request with auth" into 13
Mark Michelson [Fri, 12 Jun 2015 21:02:25 +0000 (16:02 -0500)] 
Merge "chan_sip.c: Update dialog fromtag after request with auth" into 13

10 years agoMerge "app_directory: Fix crash when using the alias option 'a'." into 13
Mark Michelson [Fri, 12 Jun 2015 21:01:54 +0000 (16:01 -0500)] 
Merge "app_directory: Fix crash when using the alias option 'a'." into 13

10 years agochan_sip.c: Update dialog fromtag after request with auth 31/631/5
Damian Ivereigh [Thu, 11 Jun 2015 13:18:48 +0000 (23:18 +1000)] 
chan_sip.c: Update dialog fromtag after request with auth

If a client sends and INVITE which is 401 rejected, then subsequently
sends a new INVITE with the auth info and uses a different fromtag
from the first INVITE, Asterisk will accept the new INVITE as part of
the original dialog - match_req_to_dialog() specifically ignores the
fromtag. However it does not update the stored dialog with the new
fromtag.

This results in Asterisk being unable to match future packets that are
part of this dialog (such as the ACK to the OK or the OK to the BYE),
and the call is dropped.

This problem was originally found when using an NEC-i SV8100-GE (NEC SIP
Card).

* After a successful match of a packet to the dialog, if the packet is
  not a SIP_RESPONSE, authentication is present and the fromtags are
  different, the stored fromtag is updated with the one from the recent
  INVITE.

ASTERISK-25154 #close
Reported by: Damian Ivereigh
Tested by: Damian Ivereigh

Change-Id: I5c16cf3b409e5ef9f2b2fe974b6bd2a45a6aa17e

10 years agochan_pjsip: Set the context and extension on the channel when created 46/646/3
Matt Jordan [Thu, 11 Jun 2015 23:52:09 +0000 (18:52 -0500)] 
chan_pjsip: Set the context and extension on the channel when created

Prior to this patch, chan_pjsip was failing to pass the endpoint's
context and the desired extension to the ast_channel_alloc_* routine.
This caused a new channel snapshot to be issued without a context and
extension, which can cause some reporting issues for users of AMI, CEL,
and other APIs. The channel driver would later set the context and
extension on the channel such that the channel would start in the
correct location in the dialplan, but the information reported in the
initial event would be incorrect.

This patch modifies the channel driver such that it now passes the
context and extension directly into the allocation routine. This
provides the information in the new channel snapshot published over
Stasis.

ASTERISK-25156 #close
Reported by: cloos

Change-Id: Ic6f8542836e596db8f662071d118e8f934fdf25e

10 years agobridge: When performing a blonde transfer update connected line information. 41/641/2
Joshua Colp [Wed, 10 Jun 2015 23:28:26 +0000 (20:28 -0300)] 
bridge: When performing a blonde transfer update connected line information.

When performing a blonde transfer the code uses the old masquerade
mechanism to move a channel around. As a result of this certain information,
such as connected line, is moved between the channels involved. Upon
completion of the move a frame is queued which is supposed to update the
connected line information on the channel. This does not occur as the
code considers it a redundant update since the masquerade operation
updated the channel (but did not inform it of the new connected line
information). The code also does not queue a connected line update
to be handled by the thread handling the channel. Without this any
other channel that may be loosely involved does not know it is
talking to a different caller.

This change does the following to resolve this:

1. The indicated connected line information is cleared upon
completion of the masquerade operation when doing a blonde transfer.
This prevents the connected line update from being considered
redundant.

2. A connected line update frame is now queued upon the completion
of the masquerade operation so any other channel loosely involved
knows that there is a different caller.

ASTERISK-25157 #close
Reported by: Joshua Colp

Change-Id: Ibb8798184a1dab3ecd35299faecc420034adbf20

10 years agoapp_directory: Fix crash when using the alias option 'a'. 38/638/1
Richard Mudgett [Thu, 11 Jun 2015 19:39:45 +0000 (14:39 -0500)] 
app_directory: Fix crash when using the alias option 'a'.

The voicemail.conf mailbox key/value pair is defined as:
<mailbox>=[<password>[,<full-name>[,<email>[,<pager>[,<options>]]]]]
Where all fields in the value including the field values are optional.

Since the parsing code for the mailbox key/value pair is sloppy, this
patch tightens the parsing for the directory information.

* Renamed the 'pos' and 'bufptr' variables to 'name' and 'options'
respectively in search_directory_sub().  Those names make more sense.

* Made sure that search_directory_sub() is dealing with the voicemail.conf
mailbox options field if it even exists when looking for the 'hidefromdir'
and 'alias' options.

* Fix crash if a voicemail.conf mailbox is just
<mailbox>=<password>,<name> when the 'a' option is used.  If there were no
fields after the name then the 'options' pointer was not checked for NULL.

* Fix users.conf alias processing if the 'a' option is used.  The wrong
variable was used.

ASTERISK-25087 #close
Reported by: Chet Stevens

Change-Id: I86052ea77307beddddba5279824d39dc0d593374

10 years agoMerge "res_pjsip.h: Fix some doxygen comments." into 13
Mark Michelson [Wed, 10 Jun 2015 20:53:35 +0000 (15:53 -0500)] 
Merge "res_pjsip.h: Fix some doxygen comments." into 13

10 years agores_pjsip.h: Fix some doxygen comments. 29/629/1
Richard Mudgett [Tue, 9 Jun 2015 20:31:25 +0000 (15:31 -0500)] 
res_pjsip.h: Fix some doxygen comments.

Change-Id: I4615771077c3c6a0a7273da6d7b5f77af7e8d976

10 years agotaskprocessor.c: Remove extra unref from off-nominal path. 28/628/1
Richard Mudgett [Fri, 5 Jun 2015 18:46:25 +0000 (13:46 -0500)] 
taskprocessor.c: Remove extra unref from off-nominal path.

Change-Id: Iee3bd8c8a528776056972066698fe735f0f6cf60

10 years agochan_iax2: Prevent deadlock between hangup and sending lagrq/ping 21/621/1
Yousf Ateya [Mon, 20 Apr 2015 21:00:00 +0000 (23:00 +0200)] 
chan_iax2: Prevent deadlock between hangup and sending lagrq/ping

channels/chan_iax.c: Prevent the deadlock between iax2_hangup and send_lagrq/
send_ping. This deadlock happens because the scheduled task send_lagrq(or
send_ping) starts execution after the call hangup procedure starts but before
it deletes the tasks in the scheduler.

The solution is to delete scheduled lagrq (and ping) task asynchronously
(i.e. schedule AST_SCHED_DEL for these tasks); By this, AST_SCHED_DEL will
be called in a new context (doesn't have callno locked).

This commit also cleans up the procedure of sending LAGRQ and PING.

main/sched.c: Do not assert when deleting non existant entry from scheduler.
This assert seems to be the reason for a lot of awkward code to avoid it.

ASTERISK-24983 #close
Reported by: Y Ateya

Change-Id: I03bec1fc8faacb89630269e935fa667c6d6c080c

10 years agoMerge "weakref attribute detection broken with gcc 4.6 and higher" into 13
Mark Michelson [Wed, 10 Jun 2015 15:38:26 +0000 (10:38 -0500)] 
Merge "weakref attribute detection broken with gcc 4.6 and higher" into 13

10 years agores_pjsip_transport_websocket: Fix use-after-free bugs. 19/619/1
Ivan Poddubny [Sun, 31 May 2015 17:37:40 +0000 (20:37 +0300)] 
res_pjsip_transport_websocket: Fix use-after-free bugs.

This patch fixes use-after-free bugs caught by AddressSanitizer.

1. PJSIP transport manager may decide to destroy transport on its own.
For example, when the contact registered via websocket has not renewed
its registration in time. The transport was destoyed, but the websocket
listener thread was still active until the socket closes, and then tried
to call transport_shutdown on transport that has been freed.

Also, the transport destructor accessed wstransport->rdata.tp_info.pool
right after freeing memory that contained wstransport itself.

This patch converts transport to an ao2 object, allowing it to be
refcounted, so that it is available until both websocket listener and
pjsip transport manager are finished with it.

2. The websocket listener deletes the last reference on websocket session
when the tcp connection is closed, and it gets destroyed, but
the transport manager may still use it, for example when disconnect
happens in the middle of a SIP transaction.

A new reference to websocket session has been added that is released
with the transport to prevent this.

ASTERISK-25096 #close
Reported by: Josh Kitchens

ASTERISK-24963 #close
Reported by: Badalian Vyacheslav

Change-Id: Idc0b63eb6e459c1ddfb2430127d34b3c4d8d373b

10 years agoweakref attribute detection broken with gcc 4.6 and higher 15/615/2
ibercom [Tue, 9 Jun 2015 18:41:54 +0000 (20:41 +0200)] 
weakref attribute detection broken with gcc 4.6 and higher

GCC 4.7 Manual:
http://gcc.gnu.org/onlinedocs/gcc-4.7.4/gcc/Function-Attributes.html

weakref ("target")

A weak reference is an alias that does not by itself require a definition
to be given for the target symbol.

ASTERISK-22559 #close
Reported by: Ibercom

Change-Id: I36a136cae947b65187a697533416f9ff9a0b8cdf

10 years agoMerge "Fix unsafe uses of ast_context pointers." into 13
Matt Jordan [Tue, 9 Jun 2015 11:57:46 +0000 (06:57 -0500)] 
Merge "Fix unsafe uses of ast_context pointers." into 13

10 years agoMerge "AMI: Escape string values." into 13
Matt Jordan [Mon, 8 Jun 2015 18:16:13 +0000 (13:16 -0500)] 
Merge "AMI: Escape string values." into 13

10 years agoFix unsafe uses of ast_context pointers. 03/603/1
Corey Farrell [Mon, 8 Jun 2015 15:09:22 +0000 (11:09 -0400)] 
Fix unsafe uses of ast_context pointers.

Although ast_context_find, ast_context_find_or_create and
ast_context_destroy perform locking of the contexts table,
any context pointer can become invalid at any time that the
contexts table is unlocked. This change adds locking around
all complete operations involving these functions.

Places where ast_context_find was followed by ast_context_destroy
have been replaced with calls ast_context_destroy_by_name.

ASTERISK-25094 #close
Reported by: Corey Farrell

Change-Id: I1866b6787730c9c4f3f836b6133ffe9c820734fa

10 years agoMerge "Fixes for OS X" into 13
Joshua Colp [Fri, 5 Jun 2015 18:20:38 +0000 (13:20 -0500)] 
Merge "Fixes for OS X" into 13

10 years agoCLI: Cosmetic issue - core show uptime 93/593/1
ibercom [Thu, 4 Jun 2015 12:14:13 +0000 (14:14 +0200)] 
CLI: Cosmetic issue - core show uptime

Show uptime information ends with an unnecessary space.

Now NEEDCOMMA is better defined.

Change-Id: I11b360504a0703309ff51772ff8f672287f3c5a1

10 years agores_pjsip: Prevent access of NULL channels. 82/582/1
Mark Michelson [Wed, 3 Jun 2015 22:41:23 +0000 (17:41 -0500)] 
res_pjsip: Prevent access of NULL channels.

It is possible to receive incoming requests or responses after the channel
on an ast_sip_session has been destroyed and NULLed out. Handlers of these
sorts of requests or responses need to be prepared for the possibility
that the channel is NULL or else they could cause a crash.

While several places have been amended to deal with NULL channels, there
were still a couple of places that needed updating.

res_pjsip_dtmf_info.c: When handling incoming INFO requests, we need to
return early if there is no channel on the session.

res_pjsip_session.c: When handling a 302 response, we need to stop the
redirecting attempt if there is no channel on the session.

ASTERISK-25148 #close
reported by Mark Michelson

Change-Id: Id1a75ffc3d0eaa168b0b28188fb54d6cf9fc47a9

10 years agoAMI: Escape string values. 60/560/3
Kevin Harwell [Mon, 1 Jun 2015 16:45:30 +0000 (11:45 -0500)] 
AMI: Escape string values.

So this issue is a bit complicated. Since it is possible to pass values to AMI
that contain a '\r\n' (or other similar sequences) these values need to be
escaped. One way to solve this is to escape the values and then pass the escaped
values to the AMI variable parameter string building function. However, this
puts the onus on the pre-build function to escape all string values. This
potentially requires a fair amount of changes along with a lot of string
allocations/freeing for all values.

Surely there is a way to push this complexity down a level into the string
building function itself? This of course is possible, but ends up requiring a
way to distinguish between strings that need to be escaped and those that don't.
The best way to handle this is by introducing a new format specifier in the
format string. For instance a %s (no escape) and %S (escape). However, that is
a bit weird and unexpected.

So faced with those possibilities this patch implements a limited version of the
first option. Instead of attempting to escape all string values this patch only
escapes those values that make sense. This approach limits the number of changes
and doesn't suffer from the odd format specifier problem.

ASTERISK-24934 #close
Reported by: warren smith

Change-Id: Ib55a5b84fe0481b0f2caaaab68c566f392c0aac0

10 years agores_pjsip/location: Fix ref leak in contact_apply_handler 77/577/1
George Joseph [Wed, 3 Jun 2015 18:17:58 +0000 (12:17 -0600)] 
res_pjsip/location: Fix ref leak in contact_apply_handler

contact_apply_handler calls ast_res_pjsip_find_or_create_contact_status
to force the creation of a contact_status object whenever a new
contact is added but it didn't unref the returned object.

Added an ao2_cleanup(status) to plug the leak.

ASTERISK-25141

Change-Id: Icc1401cae142855a1abc86ab5179dfb3ee861c40
Reported-by: Corey Farrell
10 years agoFixes for OS X 72/572/1
David M. Lee [Tue, 2 Jun 2015 20:07:08 +0000 (15:07 -0500)] 
Fixes for OS X

 * Add some type casting so tv_usec can really be a long, instead of
   some strange platform specific type.

 * Add some .dylib style files to .gitignore.

 * Switch from using -Xlinker to -Wl,. For [reasons unknown][], newer
   versions of GCC, when compiling the Homebrew formula for Asterisk,
   are not properly passing the -Xlinker options to the linker. Given
   that -Wl, does exactly the [same thing][], and does it properly, this
   patch changes the -Xlinker options to use -Wl, instead.

 [reasons unknown]: http://bit.ly/1SUbEYx
 [same thing]: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

Change-Id: Id5e6b3c6cc86282ea5fca630dc3991137c5bf4dd

10 years agoMerge "res_pjsip_session: Fix in-dialog authentication." into 13
Matt Jordan [Tue, 2 Jun 2015 14:29:27 +0000 (09:29 -0500)] 
Merge "res_pjsip_session: Fix in-dialog authentication." into 13

10 years agoMerge "Fix buffer overflow in slin sample frames generation." into 13
Mark Michelson [Mon, 1 Jun 2015 21:08:29 +0000 (16:08 -0500)] 
Merge "Fix buffer overflow in slin sample frames generation." into 13

10 years agopjsip_configuration: Fix leak in persistent_endpoint_update_state. 52/552/2
Corey Farrell [Sun, 31 May 2015 01:22:00 +0000 (21:22 -0400)] 
pjsip_configuration: Fix leak in persistent_endpoint_update_state.

The loop to find the first available contact of an endpoint grabbed
contact from the iterator, then checked for offline state.  This
caused the first contact after the state was found to leak a reference.

ASTERISK-25141

Change-Id: Id0f1d87410fc63742db0594eb4b18b36e99aec08

10 years agoFix buffer overflow in slin sample frames generation. 55/555/1
Ivan Poddubny [Sun, 31 May 2015 16:33:37 +0000 (19:33 +0300)] 
Fix buffer overflow in slin sample frames generation.

The length of frames retured by sample functions was twice as large as
real, what caused global buffer overflow caught by AddressSanitizer.

ASTERISK-24717 #close
Reported by: Badalian Vyacheslav

Change-Id: Iec2fe682aef13e556684912f906bedf7c18229c6

10 years agores_pjsip/location: Fix memory leak in permanent_uri_handler 47/547/2
George Joseph [Fri, 29 May 2015 21:19:26 +0000 (15:19 -0600)] 
res_pjsip/location:  Fix memory leak in permanent_uri_handler

When permanent_uri_handler was creating the contact status
object for each contact, it wasn't unreffing it at the
end of the loop.

ASTERISK-25141 #close
Reported-by: Corey Farrell
Change-Id: I7bb127994677bb3d459f87952f8425c9b9967b12

10 years agoRevert "endpoint/stasis: Eliminate duplicate events on endpoint status change" 45/545/1
George Joseph [Fri, 29 May 2015 19:52:23 +0000 (14:52 -0500)] 
Revert "endpoint/stasis: Eliminate duplicate events on endpoint status change"

This reverts commit 35c699086ae2fd81b2473307ccb2ae79ad32375a.

Change-Id: Ia98c2b4820cf579a5b9bb75e9e05d7a233205fb7

10 years agoendpoint/stasis: Eliminate duplicate events on endpoint status change 41/541/3
George Joseph [Wed, 27 May 2015 18:22:39 +0000 (12:22 -0600)] 
endpoint/stasis: Eliminate duplicate events on endpoint status change

When an endpoint was created, it's messages were being forwarded to
both the tech endpoint topic and the all endpoints topic.  Since
the tech topic was also forwarded to all, this was resulting in
duplicate messages whenever an endpoint published.  This patch
causes the endpoint to only forward to the tech topic and lets
the tech topic forward to all.

To accomplish this, the existing stasis_cp_single_create function
(which both creates and forwards) was cloned and split into 2
functions, one that creates the topic and one that sets up the
forwarding.  This allows endpoint_internal_create to create
the topic from the endpoint_all cache without forwarding it there,
then allows it to do the forward to the tech's topic.

ASTERISK-25137 #close
Reported-by: Vitezslav Novy
ASTERISK-25116 #close
Reported-by: George Joseph <george.joseph@fairview5.com>
Tested-by: George Joseph <george.joseph@fairview5.com>
Change-Id: I26d7d4926a0861748fd3bdffe316b75b549a801c

10 years agores_pjsip_session: Fix in-dialog authentication. 35/535/2
Richard Mudgett [Tue, 26 May 2015 18:56:42 +0000 (13:56 -0500)] 
res_pjsip_session: Fix in-dialog authentication.

When the remote peer requires authentication for in-dialog requests then
re-INVITEs to the peer cause the call to be disconnected and other
in-dialog requests to the peer like MESSAGE just don't go through.

* Made session_inv_on_tsx_state_changed() handle in-dialog authentication
for re-INVITEs and other methods.  Initial INVITEs cannot be handled here
because the INVITE transaction must be restarted earlier.

* Pulled needed code from res/res_pjsip/pjsip_outbound_auth.c in
preparation for removing the file.  The generic outbound authentication
code did not work as well as anticipated.

* Created outbound_invite_auth() to only handle initial outbound INVITEs.
Re-INVITEs cannot be handled here.  The re-INVITE transaction is still in
progress and the PJSIP library cannot handle the overlapping INVITE
transactions.  Other method types should not be handled here as this code
only works on outgoing calls and we need to handle incoming and outgoing
calls.

ASTERISK-25131 #close
Reported by: Richard Mudgett

Change-Id: I12bdd7ddccc819b4ce4b091e826d1e26334601b0

10 years agores_pjsip: Add AMI events for chan_pjsip contact lifecycle changes 18/518/4
George Joseph [Thu, 21 May 2015 22:21:01 +0000 (16:21 -0600)] 
res_pjsip: Add AMI events for chan_pjsip contact lifecycle changes

Add a new ContactStatus AMI event.
Publish the following status/state changes:
Created
Removed
Reachable
Unreachable
Unknown

Contact URI, new status/state, aor and endpoint names, and the
last qualify rtt result are included in the event.

ASTERISK-25114 #close

Change-Id: Id25aae5f7122facba183273efb3e8f36c20fb61e
Reported-by: George Joseph <george.joseph@fairview5.com>
Tested-by: George Joseph <george.joseph@fairview5.com>
10 years agoMerge "Astobj2: Correctly treat hash_fn returning INT_MIN" into 13
Joshua Colp [Tue, 26 May 2015 21:07:13 +0000 (16:07 -0500)] 
Merge "Astobj2: Correctly treat hash_fn returning INT_MIN" into 13

10 years agosorcery: Fix cache creation callback. 33/533/1
Joshua Colp [Tue, 26 May 2015 12:44:18 +0000 (09:44 -0300)] 
sorcery: Fix cache creation callback.

The cache creation callback function expects to receive a sorcery_details
structure and not just a standalone object.

Change-Id: I3e4a5a137cb25292eb52d7a14cbb6daa09213450

10 years agoAstobj2: Correctly treat hash_fn returning INT_MIN 31/531/4
Ivan Poddubny [Sun, 24 May 2015 18:47:16 +0000 (21:47 +0300)] 
Astobj2: Correctly treat hash_fn returning INT_MIN

The code in astobj2_hash.c wrongly assumed that abs(int) is always > 0.
However, abs(INT_MIN) = INT_MIN and is still negative, as well as
abs(INT_MIN) % num_buckets, and as a result this led to a crash.

One way to trigger the bug is using host=::80 or 0.0.0.128 in peer
configuration section in chan_sip or chan_iax.

This patch takes the remainder before applying abs, so that bucket
number is always in range.

ASTERISK-25100 #close
Reported by: Mark Petersen

Change-Id: Id6981400ad526f47e10bcf7b847b62bd2785e899

10 years agoMerge "Stasis: Fix unsafe use of stasis_unsubscribe in modules." into 13
Matt Jordan [Sun, 24 May 2015 18:56:12 +0000 (13:56 -0500)] 
Merge "Stasis: Fix unsafe use of stasis_unsubscribe in modules." into 13