]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
9 years agoMessage.c: Clear message channel frames on cleanup 86/1186/1
Jonathan Rose [Wed, 13 May 2015 20:41:07 +0000 (15:41 -0500)] 
Message.c: Clear message channel frames on cleanup

The message channel is a special channel that doesn't actually process frames.
However, certain actions can cause frames to be placed in the channel's read
queue including the Hangup application which is called on the channel after
each message is processed. Since the channel will continually be reused for
many messages, it's necessary to flush these frames at some point.

ASTERISK-25083 #close
Reported by: Jonathan Rose

Change-Id: Idf18df73ccd8c220be38743335b5c79c2a4c0d0f
(cherry picked from commit 02c513058905dae19f28393ea840a47ae4a9e66d)

9 years agores_pjsip: Fix contact refleak on stateful responses. 79/1179/1
Mark Michelson [Wed, 2 Sep 2015 22:26:14 +0000 (17:26 -0500)] 
res_pjsip: Fix contact refleak on stateful responses.

When sending a stateful response, creation of the transaction can fail,
most commonly because we are trying to create a transaction from a
retransmitted request. When creation of the transaction fails, we end up
leaking a reference to a contact that was bumped when the response was
created.

This patch adds the missing deref and fixes the reference leak.

Change-Id: I2f97ad512aeb1b17e87ca29ae0abacb4d6395f07

9 years agopbx: Fix crash when issuing "core show hints" with long pattern match. 75/1175/1
Joshua Colp [Wed, 2 Sep 2015 17:41:10 +0000 (14:41 -0300)] 
pbx: Fix crash when issuing "core show hints" with long pattern match.

When issuing the "core show hints" CLI command a combination of both
the hint extension and context is created. This uses a fixed size
buffer expecting that the extension will not exceed maximum extension
length. When the extension is actually a pattern match this constraint
does not hold true, and the extension may exceed the maximum extension
length. In this case extra characters are written past the end of the
fixed size buffer.

This change makes it so the construction of the combined hint extension
and context can not exceed the size of the buffer.

ASTERISK-25367 #close

Change-Id: Idfa1b95d0d4dc38e675be7c1de8900b3f981f499

9 years agoPJSIP XML, XPIDF: Fix buffer size overwrite memory corruption error. 72/1172/1
Richard Mudgett [Thu, 2 Jul 2015 19:51:29 +0000 (14:51 -0500)] 
PJSIP XML, XPIDF: Fix buffer size overwrite memory corruption error.

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

9 years agores_pjsip_pubsub: re-re-fix persistent subscription storage. 69/1169/2
Mark Michelson [Tue, 1 Sep 2015 14:05:34 +0000 (09:05 -0500)] 
res_pjsip_pubsub: re-re-fix persistent subscription storage.

A recent change to res_pjsip_pubsub switched to using pjsip_msg_print as
a means of writing an appropriate packet to persistent storage. While
this partially solved the issue, it had its own problems.
pjsip_msg_print will always add a Content-Length header to the message
it prints. Frequent restarts of Asterisk can result in persistent
subscriptions being written with five or more Content-Length headers. In
addition, sometimes some apparent corruption of individual headers could
be seen.

This aims to fix the problem by not running a parsed message through an
interpreter but rather by taking the raw message and saving it. The
logic for what to save is going to be different depending on whether a
SUBSCRIBE was received from the wire or if it was pulled from
persistence. When receiving a packet from the wire, when using a
streaming transport, the rdata->pkt_info.packet may contain multiple SIP
messages or fragments. However, the rdata->msg_info.msg_buf will always
contain the current SIP message to be processed. When pulling from
persistence, though, the rdata->msg_info.msg_buf will be NULL since no
transport actually handled the packet. However, since we know that we
will always ever pull one SIP message from persistence, we are free to
save directly from rdata->pkt_info.packet instead.

ASTERISK-25365 #close
Reported by Mark Michelson

Change-Id: I33153b10d0b4dc8e3801aaaee2f48173b867855b

9 years agoFix deadlock on presence state changes. 67/1167/1
Mark Michelson [Mon, 31 Aug 2015 20:24:17 +0000 (15:24 -0500)] 
Fix deadlock on presence state changes.

A deadlock was observed where three threads were competing for different
locks:

* One thread held the hints lock and was attempting to lock a specific
  hint.
* One thread was holding the specific hint's lock and was attempting to
  lock the contexts lock
* One thread was holding the contexts lock and attempting to lock the
  hints lock.

Clearly the second thread was doing the wrong thing here. The fix for
this is to make sure that the hint's lock is not held on presence state
changes. Something similar is already done (and commented about) for
device state changes.

ASTERISK-25362 #close
Reported by Mark Michelson

Change-Id: I15ec2416b92978a4c0c08273b2d46cb21aff97e2

9 years agoMerge "res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items." into certified...
Matt Jordan [Sat, 29 Aug 2015 17:30:54 +0000 (12:30 -0500)] 
Merge "res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items." into certified/13.1

9 years agores_pjsip_sdp_rtp: Fix multiple keepalive scheduled items. 61/1161/1
Joshua Colp [Sat, 29 Aug 2015 01:22:45 +0000 (22:22 -0300)] 
res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items.

The keepalive support in res_pjsip_sdp_rtp currently assumes
that a stream will only be negotiated once. This is false.
If the stream is replaced and later added back it can be
negotiated again causing multiple keepalive scheduled items
to exist. This change explicitly deletes the existing
keepalive scheduled item before adding the new one.

The res_pjsip_sdp_rtp module also does not stop RTP
keepalives or timeout timer if the stream has been
replaced. This change adds a callback to the session media
interface to allow a media stream to be stopped without
the resources being destroyed. This allows the scheduled
items and RTP to be stopped when the stream no longer
exists.

ASTERISK-25356 #close

Change-Id: Ibe6a7cc0927c87326fd5f1c0d4ad889dbfbea1de

9 years agosched: ast_sched_del may return prematurely due to spurious wakeup 58/1158/1
Joshua Colp [Sat, 29 Aug 2015 00:57:14 +0000 (21:57 -0300)] 
sched: ast_sched_del may return prematurely due to spurious wakeup

When deleting a scheduled item if the item in question is currently
executing the ast_sched_del function waits until it has completed.
This is accomplished using ast_cond_wait. Unfortunately the
ast_cond_wait function can suffer from spurious wakeups so the
predicate needs to be checked after it returns to make sure it has
really woken up as a result of being signaled.

This change adds a loop around the ast_cond_wait to make sure that
it only exits when the executing task has really completed.

ASTERISK-25355 #close

Change-Id: I51198270eb0b637c956c61aa409f46283432be61

9 years agoMerge "Local channels: Alternate solution to ringback problem." into certified/13.1
Joshua Colp [Fri, 28 Aug 2015 11:30:55 +0000 (06:30 -0500)] 
Merge "Local channels: Alternate solution to ringback problem." into certified/13.1

9 years agoMerge "res_pjsip: Add common ast_sip_get_host_ip API." into certified/13.1
Joshua Colp [Thu, 27 Aug 2015 20:42:05 +0000 (15:42 -0500)] 
Merge "res_pjsip: Add common ast_sip_get_host_ip API." into certified/13.1

9 years agoLocal channels: Alternate solution to ringback problem. 50/1150/1
Mark Michelson [Thu, 23 Jul 2015 18:11:42 +0000 (13:11 -0500)] 
Local channels: Alternate solution to ringback problem.

Commit 54b25c80c8387aea9eb20f9f4f077486cbdf3e5d solved an issue where a
specific scenario involving local channels and a native local RTP bridge
could result in ringback still being heard on a calling channel even
after the call is bridged.

That commit caused many tests in the testsuite to fail with alarming
consequences, such as not sending DialBegin and DialEnd events, and
giving incorrect hangup causes during calls.

This commit reverts the previous commit and implements and alternate
solution. This new solution involves only passing AST_CONTROL_RINGING
frames across local channels if the local channel is in AST_STATE_RING.
Otherwise, the frame does not traverse the local channels. By doing
this, we can ensure that a playtones generator does not get started on
the calling channel but rather is started on the local channel on which
the ringing frame was initially indicated.

ASTERISK-25250 #close
Reported by Etienne Lessard

Change-Id: I3bc87a18a38eb2b68064f732d098edceb5c19f39

9 years agochan_sip: Allow call pickup to set the hangup cause. 43/1143/1
Joshua Colp [Wed, 26 Aug 2015 10:40:32 +0000 (07:40 -0300)] 
chan_sip: Allow call pickup to set the hangup cause.

The call pickup implementation in chan_sip currently sets the channel
hangup cause to "normal clearing" if call pickup is successfully
performed. This action overwrites the "answered elsewhere" hangup cause
set by the call pickup code and can result in the SIP device in
question showing a missed call when it should not.

This change sets the hangup cause to "normal clearing" as a
default initially but allows the call pickup to change it as
needed.

ASTERISK-25346 #close

Change-Id: I00ac2c269cee9e29586ee2c65e83c70e52a02cff

9 years agores_pjsip: Add common ast_sip_get_host_ip API. 38/1138/2
Joshua Colp [Tue, 25 Aug 2015 12:17:34 +0000 (09:17 -0300)] 
res_pjsip: Add common ast_sip_get_host_ip API.

Modules commonly used the pj_gethostip function for retrieving the
IP address of the host. This function does not cache the result and may
result in a DNS lookup occurring, or additional work. If the DNS
server is unreachable or network issues arise this can cause the
pj_gethostip function to block for a period of time.

This change adds an ast_sip_get_host_ip and ast_sip_get_host_ip_string
function which does the same thing but caches the host IP address at
module load time. This results in no additional work being done each
time the local host IP address is needed.

ASTERISK-25342 #close

Change-Id: I3205deb679b01fa5ac05a94b623bfd620a2abe1e

9 years agoMerge "bridge: Kick channel from bridge if hung up during action." into certified...
Mark Michelson [Mon, 24 Aug 2015 22:16:33 +0000 (17:16 -0500)] 
Merge "bridge: Kick channel from bridge if hung up during action." into certified/13.1

9 years agobridge: Kick channel from bridge if hung up during action. 35/1135/1
Joshua Colp [Mon, 24 Aug 2015 11:21:37 +0000 (08:21 -0300)] 
bridge: Kick channel from bridge if hung up during action.

When executing an action in a bridge it is possible for the
channel to be hung up without the bridge becoming aware of it.
This is most easily reproducible by hanging up when the bridge
is streaming DTMF due to a feature timeout. This change makes
it so after action execution the channel is checked to determine
if it has been hung up and if it has it is kicked from the bridge.

ASTERISK-25341 #close

Change-Id: I6dd8b0c3f5888da1c57afed9e8a802ae0a053062

9 years agores_pjsip_pubsub: On recreated notify fail deleted sub_tree is referenced 31/1131/1
Joshua Colp [Mon, 24 Aug 2015 16:04:57 +0000 (13:04 -0300)] 
res_pjsip_pubsub: On recreated notify fail deleted sub_tree is referenced

When recreating a subscription it is possible for a freed sub_tree
to be referenced when the initial NOTIFY fails to be created.

Change-Id: I681c215309aad01b21d611c2de47b3b0a6022788

9 years agores_pjsip_pubsub: On notify fail deleted sub_tree is then referenced 25/1125/2
Scott Griepentrog [Thu, 16 Apr 2015 18:20:29 +0000 (13:20 -0500)] 
res_pjsip_pubsub: On notify fail deleted sub_tree is then referenced

This change makes the send_notify of the sub_tree
not happen when the sub_tree has been deleted due
to the notify call failing, which avoids a crash.

ASTERISK-24970 #close

Change-Id: I1f20ffc08b192f59c457293b218025a693992cbf
(cherry picked from commit 8d4ce7cc2b87317005588e700b278a8cca7005c8)

9 years agores_pjsip_sdp_rtp: Restore removed NULL check. 99/1099/1
Mark Michelson [Fri, 14 Aug 2015 20:46:05 +0000 (15:46 -0500)] 
res_pjsip_sdp_rtp: Restore removed NULL check.

When sending an RTP keepalive, we need to be sure we're not dealing with
a NULL RTP instance. There had been a NULL check, but the commit that
added the rtp_timeout and rtp_hold_timeout options removed the NULL
check.

Change-Id: I2d7dcd5022697cfc6bf3d9e19245419078e79b64

9 years agoaudiohook.c: Fix MixMonitor crash when using the r() or t() options. 90/1090/2
Richard Mudgett [Thu, 13 Aug 2015 17:22:14 +0000 (12:22 -0500)] 
audiohook.c: Fix MixMonitor crash when using the r() or t() options.

The built frame format in audiohook_read_frame_both() is now set to a
signed linear format before the rx and tx frames are duplicated instead of
only for the mixed audio frame duplication.

ASTERISK-25322 #close
Reported by Sean Pimental

Change-Id: I86f85b5c48c49e4e2d3b770797b9d484250a1538

9 years agoMerge "chan_sip.c: wrong peer searched in sip_report_security_event" into certified...
Mark Michelson [Thu, 13 Aug 2015 21:12:11 +0000 (16:12 -0500)] 
Merge "chan_sip.c: wrong peer searched in sip_report_security_event" into certified/13.1

9 years agochan_sip.c: wrong peer searched in sip_report_security_event 84/1084/2
Kevin Harwell [Wed, 12 Aug 2015 17:59:53 +0000 (12:59 -0500)] 
chan_sip.c: wrong peer searched in sip_report_security_event

In chan_sip, after handling an incoming invite a security event is raised
describing authorization (success, failure, etc...). However, it was doing
a lookup of the peer by extension. This is fine for register messages, but
in the case of an invite it may search and find the wrong peer, or a non
existent one (for instance, in the case of call pickup). Also, if the peers
are configured through realtime this may cause an unnecessary database lookup
when caching is enabled.

This patch makes it so that sip_report_security_event searches by IP address
when looking for a peer instead of by extension after an invite is processed.

ASTERISK-25320 #close

Change-Id: I9b3f11549efb475b6561c64f0e6da1a481d98bc4

9 years agores_http_websocket: When shutting down a session don't close closed socket 80/1080/2
Joshua Colp [Thu, 13 Aug 2015 10:26:51 +0000 (07:26 -0300)] 
res_http_websocket: When shutting down a session don't close closed socket

Due to the use of ast_websocket_close in session termination it is
possible for the underlying socket to already be closed when the
session is terminated. This occurs when the close frame is attempted
to be written out but fails.

Change-Id: I7572583529a42a7dc911ea77a974d8307d5c0c8b

9 years agoMerge "res_http_websocket: Forcefully terminate on write errors." into certified...
Joshua Colp [Wed, 12 Aug 2015 18:43:05 +0000 (13:43 -0500)] 
Merge "res_http_websocket: Forcefully terminate on write errors." into certified/13.1

9 years agores_http_websocket: Forcefully terminate on write errors. 75/1075/1
Joshua Colp [Tue, 11 Aug 2015 10:24:30 +0000 (07:24 -0300)] 
res_http_websocket: Forcefully terminate on write errors.

The res_http_websocket module will currently attempt to close
the WebSocket connection if fatal cases occur, such as when
attempting to write out data and being unable to. When the
fatal cases occur the code attempts to write a WebSocket close
frame out to have the remote side close the connection. If
writing this fails then the connection is not terminated.

This change forcefully terminates the connection if the
WebSocket is to be closed but is unable to send the close frame.

ASTERISK-25312 #close

Change-Id: I10973086671cc192a76424060d9ec8e688602845

9 years agochan_dahdi.c: Flush the DAHDI write buffer after starting DTMF. 68/1068/1
Richard Mudgett [Mon, 10 Aug 2015 18:43:19 +0000 (13:43 -0500)] 
chan_dahdi.c: Flush the DAHDI write buffer after starting DTMF.

Pressing DTMF digits on a phone to go out on a DAHDI channel can result in
the digit not being recognized or even heard by the peer.

Phone -> Asterisk -> DAHDI/channel

Turns out the DAHDI behavior with DTMF generation (and any other generated
tones) is exposed by the "buffers=" setting in chan_dahdi.conf.  When
Asterisk requests to start sending DTMF then DAHDI waits until its write
buffer is empty before generating any samples for the DTMF tones.  When
Asterisk subsequently requests DAHDI to stop sending DTMF then DAHDI
immediately stops generating the DTMF samples.  As a result, the more
samples there are in the DAHDI write buffer the shorter the time DTMF
actually gets sent on the wire.  If there are more samples in the write
buffer than the time DTMF is supposed to be sent then no DTMF gets sent on
the wire.  With the "buffers=12,half" setting and each buffer representing
20 ms of samples then the DAHDI write buffer is going to contain around
120 ms of samples.  For DTMF to be recognized by the peer the actual sent
DTMF duration needs to be a minimum of 40 ms.  Therefore, the intended
duration needs to be a minimum of 160 ms for the peer to receive the
minimum DTMF digit duration to recognize it.

A simple and effective solution to work around the DAHDI behavior is for
Asterisk to flush the DAHDI write buffer when sending DTMF so the full
duration of DTMF is actually sent on the wire.  When someone is going to
send DTMF they are not likely to be talking before sending the tones so
the flushed write samples are expected to just contain silence.

* Made dahdi_digit_begin() flush the DAHDI write buffer after requesting
to send a DTMF digit.

ASTERISK-25315 #close
Reported by John Hardin

Change-Id: Ib56262c708cb7858082156bfc70ebd0a220efa6a

9 years agochan_dahdi.c: Lock private struct for ast_write(). 67/1067/1
Richard Mudgett [Wed, 5 Aug 2015 19:21:50 +0000 (14:21 -0500)] 
chan_dahdi.c: Lock private struct for ast_write().

There is a window of opportunity for DTMF to not go out if an audio frame
is in the process of being written to DAHDI while another thread starts
sending DTMF.  The thread sending the audio frame could be past the
currently dialing check before being preempted by another thread starting
a DTMF generation request.  When the thread sending the audio frame
resumes it will then cause DAHDI to stop the DTMF tone generation.  The
result is no DTMF goes out.

* Made dahdi_write() lock the private struct before writing to the DAHDI
file descriptor.

ASTERISK-25315
Reported by John Hardin

Change-Id: Ib4e0264cf63305ed5da701188447668e72ec9abb

9 years agores_pjsip.c: Fix crash from corrupt saved SUBSCRIBE message. 66/1066/1
Richard Mudgett [Mon, 10 Aug 2015 23:23:02 +0000 (18:23 -0500)] 
res_pjsip.c: Fix crash from corrupt saved SUBSCRIBE message.

If the saved SUBSCRIBE message is not parseable for whatever reason then
Asterisk could crash when libpjsip tries to parse the message and adds an
error message to the parse error list.

* Made ast_sip_create_rdata() initialize the parse error rdata list.  The
list is checked after parsing to see that it remains empty for the
function to return successful.

ASTERISK-25306
Reported by Mark Michelson

Change-Id: Ie0677f69f707503b1a37df18723bd59418085256

10 years agoMerge "res_pjsip: Ensure sanitized XML is NULL terminated." into certified/13.1
Joshua Colp [Fri, 7 Aug 2015 15:23:45 +0000 (10:23 -0500)] 
Merge "res_pjsip: Ensure sanitized XML is NULL terminated." into certified/13.1

10 years agores_pjsip_pubsub: More accurately persist packet. 45/1045/2
Mark Michelson [Thu, 6 Aug 2015 17:48:07 +0000 (12:48 -0500)] 
res_pjsip_pubsub: More accurately persist packet.

The pjsip_rx_data structure has a pkt_info.packet field on it that is
the packet that was read from the transport. For datagram transports,
the packet read from the transport will correspond to the SIP message
that arrived. For streamed transports, however, it is possible to read
multiple SIP messages in one packet.

In a recent case, Asterisk crashed on a system where TCP was being used.
This is because at some point, a read from the TCP socket resulted in a
200 OK response as well as an incoming SUBSCRIBE request being stored in
rdata->pkt_info.packet. When the SUBSCRIBE was processed, the
combination 200 OK and SUBSCRIBE was saved in persistent storage. Later,
a restart of Asterisk resulted in the crash because the persistent
subscription recreation code ended up building the 200 OK response
instead of a SUBSCRIBE request, and we attempted to access
request-specific data.

The fix here is to use the pjsip_msg_print() function in order to
persist SUBSCRIBE requests. This way, rather than using the raw socket
data, we use the parsed SIP message that PJSIP has given us. If we
receive multiple SIP messages from a single read, we will be sure only
to save off the relevant SIP message. There also is a safeguard put in
place to make sure that if we do end up reconstructing a SIP response,
it will not cause a crash.

ASTERISK-25306 #close
Reported by Mark Michelson

Change-Id: I4bf16f7b76a2541d10b55de82bcd14c6e542afb2

10 years agores_pjsip: Ensure sanitized XML is NULL terminated. 39/1039/2
Joshua Colp [Tue, 4 Aug 2015 21:12:59 +0000 (18:12 -0300)] 
res_pjsip: Ensure sanitized XML is NULL terminated.

The ast_sip_sanitize_xml function is used to sanitize
a string for placement into XML. This is done by examining
an input string and then appending values to an output
buffer. The function used by its implementation, strncat,
has specific behavior that was not taken into account.
If the size of the input string exceeded the available
output buffer size it was possible for the sanitization
function to write past the output buffer itself causing
a crash. The crash would either occur because it was
writing into memory it shouldn't be or because the resulting
string was not NULL terminated.

This change keeps count of how much remaining space is
available in the output buffer for text and only allows
strncat to use that amount.

Since this was exposed by the res_pjsip_pidf_digium_body_supplement
module attempting to send a large message the maximum allowed
message size has also been increased in it.

A unit test has also been added which confirms that the
ast_sip_sanitize_xml function is providing NULL terminated
output even when the input length exceeds the output
buffer size.

ASTERISK-25304 #close

Change-Id: I743dd9809d3e13d722df1b0509dfe34621398302

10 years agores_pjsip_session: Fix double re-INVITE collision crash. 41/1041/1
Richard Mudgett [Fri, 13 Feb 2015 17:21:28 +0000 (17:21 +0000)] 
res_pjsip_session: Fix double re-INVITE collision crash.

A multi-asterisk box setup with direct media enabled would occasionally
crash when two re-INVITE collisions on a call leg happen in a row.

The re-INVITE logic only had one timer struct to defer the re-INVITE.
When the second collision happens the timer struct is overwritten and put
into the timer heap again.  Resources for the first timer are leaked and
the heap has two positions occupied by the same timer struct.  Now the
heap ordering is potentially corrupted, the timer will fire twice, and any
resources allocated for the second timer will be released twice.

* The solution is to put the collided re-INVITE into the delayed requests
queue with all the other delayed requests and cherry pick the next request
that can come off the queue when an event happens.

* Changed to put delayed BYE requests at the head of the delayed queue.
There is no sense in processing delayed UPDATEs and re-INVITEs when a BYE
has been requested.

* Made the start of a BYE request flush the delayed requests queue to
prevent a delayed request from overlapping the BYE transaction.  I saw a
few cases where a delayed re-INVITE got started after the BYE transaction
started.

* Changed the delayed_request struct to use an enum instead of a string
for the request method.  Cherry picking the queue is easier with an enum
than string comparisons and the compiler can warn if a switch statement
does not cover all defined enum values.

* Improved the debug output to give more information.  It helps to know
which channel is involved with an endpoint.  Trunks can have many channels
associated with the endpoint at the same time.

ASTERISK-24727 #close
Reported by: Mark Michelson

Review: https://reviewboard.asterisk.org/r/4414/

Change-Id: Ib05700c3a13ceac53b17d66099ef0d296a5e1863

10 years agoFix problem where a hung channel could occur on a failed blind transfer. 76/976/1
Mark Michelson [Fri, 16 Jan 2015 22:12:25 +0000 (22:12 +0000)] 
Fix problem where a hung channel could occur on a failed blind transfer.

Different clients react differently to being told that a blind transfer
has failed. Some will simply send a BYE and be done with it. Others will
attempt to reinvite themselves back onto the call.

In the latter case, we were creating a new channel and then leaving it to
sit forever doing nothing. With this code change, that new channel will
not be created and the dialog with the transferring channel will be cleaned
up properly.

ASTERISK-24624 #close
Reported by Zane Conkle

Review: https://reviewboard.asterisk.org/r/4339

Change-Id: I76e440e08e603c1eea40a14951e7b171c0472a55

10 years agopjsip: Add rtp_timeout and rtp_timeout_hold endpoint options. 40/940/2
Joshua Colp [Sat, 18 Jul 2015 16:16:10 +0000 (13:16 -0300)] 
pjsip: Add rtp_timeout and rtp_timeout_hold endpoint options.

This change adds support for the 'rtp_timeout' and 'rtp_timeout_hold'
endpoint options. These allow the channel to be hung up if RTP
is not received from the remote endpoint for a specified number of
seconds.

ASTERISK-25259 #close

Change-Id: I3f39daaa7da2596b5022737b77799d16204175b9

10 years agoMerge "res_pjsip: Add rtp_keepalive endpoint option." into certified/13.1
Joshua Colp [Mon, 20 Jul 2015 20:52:09 +0000 (15:52 -0500)] 
Merge "res_pjsip: Add rtp_keepalive endpoint option." into certified/13.1

10 years agores_pjsip: Add rtp_keepalive endpoint option. 65/865/5
Mark Michelson [Thu, 9 Jul 2015 19:17:53 +0000 (14:17 -0500)] 
res_pjsip: Add rtp_keepalive endpoint option.

This adds an "rtp_keepalive" option for PJSIP endpoints. Similar to the
chan_sip option, this specifies an interval, in seconds, at which we
will send RTP comfort noise frames. This can be useful for keeping RTP
sessions alive as well as keeping NAT associations alive during lulls.

ASTERISK-25242 #close
Reported by Mark Michelson

Change-Id: I683bdc206c8c7def586ecaa64dcf2b86550be3bf

10 years agoMerge "chan_pjsip: Don't change formats when frame of unsupported format is received...
Matt Jordan [Mon, 20 Jul 2015 12:31:40 +0000 (07:31 -0500)] 
Merge "chan_pjsip: Don't change formats when frame of unsupported format is received." into certified/13.1

10 years agochan_pjsip: Don't change formats when frame of unsupported format is received. 04/904/3
Joshua Colp [Thu, 16 Jul 2015 14:46:14 +0000 (11:46 -0300)] 
chan_pjsip: Don't change formats when frame of unsupported format is received.

Receipt of an RTP packet currently causes the formats on an PJSIP channel to
change to the format of the RTP packet. In some off-nominal cases it's possible
for this to be a format that has not been configured or negotiated. This change
makes it so only formats explicitly configured on the endpoint are allowed.

ASTERISK-25258 #close

Change-Id: If93d641fb6418a285928839300d7854cab8c1020

10 years agoMerge "strings.h: Fix issues with escape string functions." into certified/13.1
Matt Jordan [Fri, 17 Jul 2015 13:50:37 +0000 (08:50 -0500)] 
Merge "strings.h: Fix issues with escape string functions." into certified/13.1

10 years agostrings.h: Fix issues with escape string functions. 19/919/1
Richard Mudgett [Wed, 15 Jul 2015 20:40:32 +0000 (15:40 -0500)] 
strings.h: Fix issues with escape string functions.

Fixes for issues with the ASTERISK-24934 patch.

* Fixed ast_escape_alloc() and ast_escape_c_alloc() if the s parameter is
an empty string.  If it were an empty string the functions returned NULL
as if there were a memory allocation failure.  This failure caused the AMI
VarSet event to not get posted if the new value was an empty string.

* Fixed dest buffer overwrite potential in ast_escape() and
ast_escape_c().  If the dest buffer size is smaller than the space needed
by the escaped s parameter string then the dest buffer would be written
beyond the end by the nul string terminator.  The num parameter was really
the dest buffer size parameter so I renamed it to size.

* Made nul terminate the dest buffer if the source string parameter s was
an empty string in ast_escape() and ast_escape_c().

* Updated ast_escape() and ast_escape_c() doxygen function description
comments to reflect reality.

* Added some more unit test cases to /main/strings/escape to cover the
empty source string issues.

ASTERISK-25255 #close
Reported by: Richard Mudgett

Change-Id: Id77fc704600ebcce81615c1200296f74de254104

10 years agores_parking: Fix crash if ATTENDEDTRANSFER set empty before Park. 16/916/1
Richard Mudgett [Tue, 14 Jul 2015 19:36:42 +0000 (14:36 -0500)] 
res_parking: Fix crash if ATTENDEDTRANSFER set empty before Park.

setup_park_common_datastore() was assuming that a non-NULL string returned
for the ATTENDEDTRANSFER and BLINDTRANSFER channel variables are not empty
strings.  Things got crashy as a result.

* Made setup_park_common_datastore() treat the channel variable values the
same whether they are NULL or empty for ATTENDEDTRANSFER and
BLINDTRANSFER.

ASTERISK-25254 #close
Reported by: Richard Mudgett

Change-Id: I9a9c174b33f354f35f82cc6b7cea8303adbaf9c2

10 years agobridge_native_rtp.c: Don't start native RTP bridging after attended transfer. 57/857/2
Joshua Colp [Thu, 9 Jul 2015 14:18:11 +0000 (11:18 -0300)] 
bridge_native_rtp.c: Don't start native RTP bridging after attended transfer.

The bridge_native_rtp module adds a frame hook to channels which are in
a native RTP bridge. This frame hook is used to intercept when a hold
or unhold frame traverses the bridge so native RTP can be stopped or
started as appropriate. This is expected but exposes a specific bug
when attended transfers are involved.

Upon completion of an attended transfer an unhold frame is queued up
to take one of the channels involved off hold. After this is done
the channel is moved between bridges.

When the frame hook is involved in this case for the unhold it
releases the channel lock and acquires the bridge lock. This
allows the bridge core to step in and move the channel
(potentially changing the bridging techology) from another thread.
Once completed the bridge lock is released by the bridge core.
The frame hook is then able to acquire the bridge lock and
wrongfully starts native RTP again, despite the channel no longer
being in the bridge or needing to start native RTP. In fact at
this point the frame hook is no longer attached to the channel.

This change makes it so the native RTP bridge data is available to
the frame hook when it is invoked. Whether the frame hook has
been detached or not is stored on the native RTP bridge data and
is checked by the frame hook before starting or stopping native
RTP bridging. If the frame hook has been detached it does nothing.

ASTERISK-25240 #close

Change-Id: I13a73186a05f4e5a764f81e5cd0ccec1ed1891d2

10 years agosorcery: Fix cache creation callback. 41/841/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: Id2a9e5f271c466686e6d0def461fa50c8b2cae53

10 years agores_sorcery_memory_cache: Remove ASTERISK_REGISTER_FILE() macro. 37/837/2
Mark Michelson [Wed, 8 Jul 2015 19:39:40 +0000 (14:39 -0500)] 
res_sorcery_memory_cache: Remove ASTERISK_REGISTER_FILE() macro.

This was part of the backport of res_sorcery_memory_cache from master
but will not compile in 13.

Change-Id: I27b3d833acda9dd1770fdbe594964197b93779b0

10 years agores_sorcery_memory_cache: Execute stale unit test last. 35/835/1
Joshua Colp [Mon, 6 Jul 2015 14:24:43 +0000 (11:24 -0300)] 
res_sorcery_memory_cache: Execute stale unit test last.

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

10 years agores_sorcery_memory_cache: Remove 'prefetch' option. 34/834/1
Joshua Colp [Wed, 17 Jun 2015 12:00:21 +0000 (09:00 -0300)] 
res_sorcery_memory_cache: Remove 'prefetch' option.

To prevent confusion I am removing the prefetch option until such
time as it is implemented. All other functionality, however, has
been implemented.

ASTERISK-25067

Change-Id: I9ce6aa3e5c6c5bc3c5baa8ff90fa036d73939895

10 years agotest_sorcery_memory_cache_thrash: Add unit tests for thrashing the memory cache. 33/833/1
Joshua Colp [Tue, 2 Jun 2015 15:20:00 +0000 (12:20 -0300)] 
test_sorcery_memory_cache_thrash: Add unit tests for thrashing the memory cache.

This change adds a CLI command which can perform memory cache thrashing as well
as unit tests which perform thrashing under the following configurations:

1. Low number of unique objects that go stale after 1 second
2. Low number of unique objects that expire after 1 second
3. Low number of unique objects which are constantly updated
4. Large number of unique objects which exceed a defined cache size
5. Large number of unique objects which exceed a defined cache size
   that also expire and go stale rapidly
6. Large number of unique objects which expire and go stale rapidly
7. Large number of unique objects

For all of the above there are a large number of threads constantly
attempting to retrieve random objects and each test runs for a few
seconds.

ASTERISK-25067
Reported by: Matt Jordan

Change-Id: I8c8ceff977332c80ed4a31f10d694d48552b2f78

10 years agores_sorcery_memory_cache: Implement expire_on_reload option. 32/832/1
Joshua Colp [Thu, 4 Jun 2015 18:11:44 +0000 (15:11 -0300)] 
res_sorcery_memory_cache: Implement expire_on_reload option.

This change implements the expire_on_reload option for memory caches.
If enabled and a reload is performed all objects within the cache
will be expired and the cache emptied.

ASTERISK-25067
Reported by: Matt Jordan

Change-Id: Id46aa1957d660556700e689e195eed57c989b85e

10 years agores_sorcery_memory_cache: Add test event when a refresh occurs. 31/831/1
Joshua Colp [Thu, 4 Jun 2015 10:33:30 +0000 (07:33 -0300)] 
res_sorcery_memory_cache: Add test event when a refresh occurs.

This change adds a testsuite event for when a refresh occurs.
This is useful as it provides a guaranteed mechanism of knowing when
it has occurred instead of waiting an arbitrary amount of time.

ASTERISK-25067
Reported by: Matt Jordan

Change-Id: Iaa6b8d2d6bab7f99ee08e1c8908b8272a8987e65

10 years agores_sorcery_memory_cache: Add CLI commands and AMI actions. 30/830/1
Joshua Colp [Tue, 26 May 2015 12:34:47 +0000 (09:34 -0300)] 
res_sorcery_memory_cache: Add CLI commands and AMI actions.

This change adds the following CLI commands and AMI actions:

sorcery memory cache show
sorcery memory cache dump
sorcery memory cache expire
sorcery memory cache stale

SorceryMemoryCacheExpire
SorceryMemoryCacheExpireObject
SorceryMemoryCacheStale
SorceryMemoryCacheStaleObject

These allow both examination and manipulation of sorcery memory
caches from external sources.

Cached objects can be explicitly expired from a cache or marked
as stale. If expired they are immediately removed. If marked as
stale they will be background refreshed when next retrieved.

ASTERISK-25067
Reported by Matt Jordan

Change-Id: I68e03cfd8c34b5e07f4b6ee4fd93a3f4a00a3d9e

10 years agores_sorcery_memory_cache: Add support for refreshing stale objects. 29/829/1
Mark Michelson [Tue, 26 May 2015 18:01:24 +0000 (13:01 -0500)] 
res_sorcery_memory_cache: Add support for refreshing stale objects.

This change introduces a check of object_lifetime_stale when retrieving
cached objects. If the amount of time the object has been in the cache
exceeds the lifetime, then a task is scheduled to update the cached
object based on an object retrieved from other sorcery wizards instead.

To prevent the cached object from being retrieved during a refresh,
thread-local storage is used to mark the thread as being a stale object
update. This results in the cache returning no object, leading to
sorcery querying other wizards for the object instead.

A test has been added for stale objects as well. This test ensures that
stale objects are retrieved the same as freshly-cached objects. The test
also ensures that after an object is stale, changes in the backend are
reflected in the cache, to include if the object has been deleted from
the backend.

ASTERISK-25067
Reported by Matt Jordan

Change-Id: I9bd7c049adf6939bfe2899f393c2bfbbf412d217

10 years agores_sorcery_memory_cache: Add support for object_lifetime_maximum. 28/828/1
Joshua Colp [Wed, 20 May 2015 22:35:54 +0000 (19:35 -0300)] 
res_sorcery_memory_cache: Add support for object_lifetime_maximum.

This makes the "object_lifetime_maximum" option operational.

On the addition of an object to an empty memory cache a scheduled
task is created which, when invoked, expires objects from the cache
which have exceeded their lifetime. If more objects have been added
the remaining life of the oldest object is used to schedule the
next invocation of the scheduled task.

If the oldest object is removed from the cache before it can be
expired automatically the scheduled task is cancelled, if possible,
and the lifetime of the next oldest is used to schedule the task.

If during these two operations no additional objects exist in the
cache then no task is scheduled.

An additional unit test has been added which verifies this
functionality.

ASTERISK-25067
Reported by: Matt Jordan

Change-Id: I87409674674a508e7717ee20739ca15cec6ba7b6

10 years agores_sorcery_memory_cache: Add support for maximum_objects. 27/827/1
Mark Michelson [Wed, 20 May 2015 20:19:27 +0000 (15:19 -0500)] 
res_sorcery_memory_cache: Add support for maximum_objects.

This makes the "maximum_objects" option operational.

A heap has been added alongside the hash table in the cache. When
objects are added to the cache, they are also added to the heap.
Similarly, when objects are removed from the cache, they are removed
from the heap.

The heap's use comes into play when an item is to be added to a "full"
cache. When the cache is full, the oldest item is removed from the
cache, using the heap to determine the oldest item.

A unit test has been added that verifies that the maximum_objects option
works as expected and that the oldest object is removed from the cache
when an object beyond the maximum is added.

ASTERISK-25067 #close
Reported by Matt Jordan

Change-Id: I490658830e9c4cbf0b3051e4cdc4913cf9f1b73a

10 years agores_sorcery_memory_cache: Add basic module implementation. 17/817/2
Joshua Colp [Sat, 16 May 2015 22:02:50 +0000 (19:02 -0300)] 
res_sorcery_memory_cache: Add basic module implementation.

This change adds a basic res_sorcery_memory_cache module which implements
configuration option parsing, configuration file parsing for threading,
sorcery interface implementation, and unit tests.

Objects can be added, updated, deleted, and retrieved from the memory
cache. Automatic expiration and stale handling will be added in the
future.

Note that unit tests exist within the module itself in case the
threading done as a result of expiration results in asynchronous
actions (which it likely will). Providing access and a notification
mechanism for an external test module would be complicated and
not worth it.

ASTERISK-25067 #close
Reported by: Matt Jordan

Change-Id: Id8a6a357ef5a83d466f81eee56a67d13eeb118b9

10 years agoapp: Add functions to swap vm function table 76/776/2
Jonathan Rose [Thu, 2 Jul 2015 22:03:51 +0000 (17:03 -0500)] 
app: Add functions to swap vm function table

This patch adds function-mocking methods for testing voicemail
features in external modules. It is being pulled over from r432556
on SVN because DPMA won't presently compile with TEST_FRAMEWORK
set in Asterisk 13.1 certified.

Change-Id: I1c2cf6d5a8589104154a86538ecd3f62a2694681

10 years agoMerge "res/res_corosync: Always decline module load, instead of failing" into certifi...
Joshua Colp [Tue, 30 Jun 2015 12:35:25 +0000 (07:35 -0500)] 
Merge "res/res_corosync: Always decline module load, instead of failing" into certified/13.1

10 years agores/res_corosync: Always decline module load, instead of failing 48/748/1
George Joseph [Wed, 22 Apr 2015 21:22:10 +0000 (15:22 -0600)] 
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 agores_sorcery_realtime: Fix leak of sorcery object type. 46/746/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 agores_pjsip_nat: Adjust when contact should be rewritten. 37/737/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 agoMerge "res_pjsip_mwi: Set up unsolicited MWI upon registration." into certified/13.1
Mark Michelson [Fri, 26 Jun 2015 16:27:43 +0000 (11:27 -0500)] 
Merge "res_pjsip_mwi: Set up unsolicited MWI upon registration." into certified/13.1

10 years agores_pjsip_refer: Prevent sending duplicate headers. 31/731/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...
Matt Jordan [Fri, 26 Jun 2015 16:00:13 +0000 (11:00 -0500)] 
Merge "AMI: Add Linkedid to the standard channel snapshot AMI event headers." into certified/13.1

10 years agores_pjsip_nat: Rewrite route set when required. 24/724/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 agoAMI: Add Linkedid to the standard channel snapshot AMI event headers. 28/728/1
Richard Mudgett [Tue, 23 Jun 2015 19:34:29 +0000 (14:34 -0500)] 
AMI: Add Linkedid to the standard channel snapshot AMI event headers.

ASTERISK-25189 #close
Reported by: John Hardin

Change-Id: I2b1778c3fdc1dca0ed55db4e3a639eddfb16c2ac

10 years agores_pjsip_mwi: Set up unsolicited MWI upon registration. 20/720/1
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 agoMerge "bridge: When performing a blonde transfer update connected line information...
Matt Jordan [Sat, 13 Jun 2015 13:36:49 +0000 (08:36 -0500)] 
Merge "bridge: When performing a blonde transfer update connected line information." into certified/13.1

10 years agobridge: When performing a blonde transfer update connected line information. 43/643/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'. 40/640/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 "AMI: Escape string values." into certified/13.1
Joshua Colp [Mon, 8 Jun 2015 18:16:35 +0000 (13:16 -0500)] 
Merge "AMI: Escape string values." into certified/13.1

10 years ago.version: Update for certified/13.1-cert3-rc1
Matt Jordan [Mon, 8 Jun 2015 17:28:41 +0000 (12:28 -0500)] 
.version: Update for certified/13.1-cert3-rc1

10 years ago.lastclean: Update for certified/13.1-cert3-rc1
Matt Jordan [Mon, 8 Jun 2015 17:28:41 +0000 (12:28 -0500)] 
.lastclean: Update for certified/13.1-cert3-rc1

10 years agorealtime: Add database scripts for certified/13.1-cert3-rc1
Matt Jordan [Mon, 8 Jun 2015 17:28:41 +0000 (12:28 -0500)] 
realtime: Add database scripts for certified/13.1-cert3-rc1

10 years agoAMI: Escape string values. 02/602/1
Kevin Harwell [Mon, 8 Jun 2015 14:43:53 +0000 (09:43 -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: Prevent access of NULL channels. 83/583/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 agores_pjsip_refer: Fix crash from a REFER and BYE collision. 66/566/1
Richard Mudgett [Tue, 17 Feb 2015 15:34:10 +0000 (15:34 +0000)] 
res_pjsip_refer: Fix crash from a REFER and BYE collision.

Analyzing a one-off crash on a busy system showed that processing a REFER
request had a NULL session channel pointer.  The only way I can think of
that could cause this is if an outgoing BYE transaction overlapped the
incoming REFER transaction in a collision.  Asterisk sends a BYE while the
phone sends a REFER to complete an attended transfer.

* Made check the session channel pointer before processing an incoming
REFER request in res_pjsip_refer.

* Fixed similar crash potential for res_pjsip supplement incoming request
processing for res_pjsip_sdp_rtp INFO, res_pjsip_caller_id INVITE/UPDATE,
res_pjsip_messaging MESSAGE, and res_pjsip_send_to_voicemail REFER
messages.

* Made res_pjsip_messaging respond to a message body too large with a 413
instead of ignoring it.

ASTERISK-24700 #close
Reported by: Zane Conkle

Review: https://reviewboard.asterisk.org/r/4417/
........

Merged revisions 431898 from http://svn.asterisk.org/svn/asterisk/branches/13

Change-Id: I57878adc0846dd942a699ad36dcec9cba5e57994

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

10 years agores_pjsip: config option 'timers' can't be set to 'no' 62/562/1
Kevin Harwell [Mon, 6 Apr 2015 19:23:57 +0000 (19:23 +0000)] 
res_pjsip: config option 'timers' can't be set to 'no'

When setting the configuration option 'timers' equal to 'no' the bit flag was
not properly negated. This patch clears all associated flags and only sets the
specified one. pjsip will handle any necessary flag combinations. Also went
ahead and did similar for the '100rel' option.

ASTERISK-24910 #close
Reported by: Ray Crumrine
Review: https://reviewboard.asterisk.org/r/4582/
........

Merged revisions 434131 from http://svn.asterisk.org/svn/asterisk/branches/13

Change-Id: Ibbc25d4592aabf7596ef473447d630961f88c217

10 years agores_pjsip_session: Fix in-dialog authentication. 59/559/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 agoapp_voicemail: fix moving when old messages full 65/465/1
Jonathan Rose [Tue, 12 May 2015 22:45:09 +0000 (17:45 -0500)] 
app_voicemail: fix moving when old messages full

When completing voicemail playback of a message in the 'INBOX', the
message gets moved to the 'Old' messages folder. Without this patch, if
the 'Old' folder is already at its set limit, then the 'INBOX' message will
simply be deleted. With this patch, the flag to delete the message will be
removed if the save_to_folder function indicates that the message could
not be moved due to a full folder.

ASTERISK-25082 #close
Reported by: Jonathan Rose
Review: https://gerrit.asterisk.org/#/c/448/

Change-Id: I2be440a09f42e2d06d50975c40d1ad7f836ecb3f

10 years agochan_dahdi/sig_pri: Fix crash on ISDN call hangup collision. 57/457/1
Richard Mudgett [Tue, 12 May 2015 22:34:45 +0000 (17:34 -0500)] 
chan_dahdi/sig_pri: Fix crash on ISDN call hangup collision.

If an ISDN call is hungup by both sides at the same time a crash could
happen.

* Added missing NULL checks for the owner channel after calling
pri_queue_pvt_cause_data() in two places.  Code after those calls need to
check the owner channel pointer for NULL before use because
pri_queue_pvt_cause_data() needs to do deadlock avoidance to lock the
owner and the owner may get hung up.

ASTERISK-21893 #close
Reported by:  Alexandr Gordeev

Change-Id: Ica3e266ebc7a894b41d762326f08653e1904bb9a

10 years agoMerge "bridge.c: NULL app causes crash during attended transfer" into certified/13.1
Joshua Colp [Thu, 7 May 2015 20:22:24 +0000 (15:22 -0500)] 
Merge "bridge.c: NULL app causes crash during attended transfer" into certified/13.1

10 years agobridge.c: NULL app causes crash during attended transfer 98/398/1
Kevin Harwell [Thu, 16 Apr 2015 15:51:50 +0000 (10:51 -0500)] 
bridge.c: NULL app causes crash during attended transfer

Due to a race condition there was a chance that during an attended transfer the
channel's application would return NULL. This, of course, would cause a crash
when attempting to access the memory. This patch retrieves the channel's app
at an earlier time in processing in hopes that the app name is available.
However, if it is not then "unknown" is used instead. Since some string value
is now always present the crash can no longer occur.

ASTERISK-24869 #close
Reported by: viniciusfontes
Review:

Change-Id: I5134b84c4524906d8148817719d76ffb306488ac

10 years agores_pjsip_exten_state: Fix race condition between sending NOTIFY and termination 91/391/1
Joshua Colp [Wed, 6 May 2015 18:24:29 +0000 (15:24 -0300)] 
res_pjsip_exten_state: Fix race condition between sending NOTIFY and termination

The res_pjsip_exten_state module currently has a race condition between
processing the extension state callback from the PBX core and processing
the subscription shutdown callback from res_pjsip_pubsub. There is currently
no synchronization between the two. This can present a problem as while
the SIP subscription will remain valid the tree it points to may not.
This is in particular a problem as a task to send a NOTIFY may get queued
which will try to use the tree that may no longer be valid.

This change does the following to fix this problem:

1. All access to the subscription tree is done within the task that
sends the NOTIFY to ensure that no other thread is modifying or
destroying the tree. This task executes on the serializer for the
subscriptions.

2. A reference to the subscription serializer is kept to ensure it
remains valid for the lifetime of the extension state subscription.

3. The NOTIFY task has been changed so it will no longer attempt
to send a NOTIFY if the subscription has already been terminated.

ASTERISK-25057 #close
Reported by: Matt Jordan

Change-Id: I0b3cd2fac5be8d9b3dc5e693aaa79846eeaf5643

10 years agoMerge "res_pjsip / res_pjsip_multihomed: Use the correct transport and addressing...
Joshua Colp [Wed, 6 May 2015 10:56:13 +0000 (05:56 -0500)] 
Merge "res_pjsip / res_pjsip_multihomed: Use the correct transport and addressing information on UAS sessions." into certified/13.1

10 years agores_pjsip / res_pjsip_multihomed: Use the correct transport and addressing informatio... 64/364/1
Joshua Colp [Mon, 19 Jan 2015 13:18:32 +0000 (13:18 +0000)] 
res_pjsip / res_pjsip_multihomed: Use the correct transport and addressing information on UAS sessions.

The first thing this patch fixes is UAS dialogs. Previously if a transport was
configured on an endpoint and an inbound session was created there was no guarantee
that requests sent on the dialog would use the correct transport and address
information. This has now been fixed so an explicitly configured transport
is taken into account.

The second thing this patch fixes is res_pjsip_multihomed. The res_pjsip_multihomed
module attempts to determine what transport a message should go out on and what
addressing information should go into the message itself. In a scenario where
multiple transports exist bound to the same IP address but a different port the
code would incorrectly alter the transport and change the message to the wrong
transport. This change makes the res_pjsip_multihomed module smarter so it will
only change the transport and address information in the message when it is
possible and makes sense.

ASTERISK-24615 #close
Reported by: David Justl

Change-Id: I5b57362201cc8c6555834ec8707e9fbddeff7904

10 years agostasis: Fix dial masquerade datastore lifetime 59/359/1
Joshua Colp [Mon, 4 May 2015 17:16:24 +0000 (14:16 -0300)] 
stasis: Fix dial masquerade datastore lifetime

A recent change went into Asterisk which added reference counts to the
channels stored in a dial masquerade datastore. Unfortunately this
included a reference to the caller in a dialing operation. While all
of the dialed targets have the datastore removed from them upon dialing
completion this did not occur for the caller, causing it to have a
reference to itself that could go never go away (as it depended on
the destruction of the datastore which only happened when the channel
was destroyed). This resulted in the caller channel remaining on the
system despite it having hung up.

This change does the following to fix this issue:

1. The dial masquerade datastore is now removed from the caller upon
dialing completion, just like the dialed targets.
2. Upon destruction of the caller all the dialed targets are also
removed from the dial masquerade datastore (just in case).
3. The reference to the caller has been removed as it should not be
possible for the datastore to now be valid/useful after the lifetime
of the caller has ended.

ASTERISK-25025 #close

Change-Id: I1ef4ca5ca04980028604cc2af5d2992ac3431b3f

10 years agochan_dahdi: Add the chan_dahdi.conf force_restart_unavailable_chans option. 26/326/1
Richard Mudgett [Wed, 29 Apr 2015 19:29:10 +0000 (14:29 -0500)] 
chan_dahdi: Add the chan_dahdi.conf force_restart_unavailable_chans option.

Some telco switches occasionally ignore ISDN RESTART requests.  The fix
for ASTERISK-19608 added an escape clause for B channels in the restarting
state if the telco ignores a RESTART request.  If the telco fails to
acknowledge the RESTART then Asterisk will assume the telco acknowledged
the RESTART on the second call attempt requesting the B channel by the
telco.  The escape clause is good for dealing with RESTART requests in
general but it does cause the next call for the restarting B channel to be
rejected if the telco insists the call must go on that B channel.

chan_dahdi doesn't really need to issue a RESTART request in response to
receiving a cause 44 (Requested channel not available) code.  Sending the
RESTART in such a situation is not required (nor prohibited) by the
standards.  I think chan_dahdi does this for historical reasons to deal
with buggy peers to get channels unstuck in a similar fashion as the
chan_dahdi.conf resetinterval option.

* Add the chan_dahdi.conf force_restart_unavailable_chans compatability
option that when disabled will prevent chan_dahdi from trying to RESTART
the channel in response to a cause 44 code.

ASTERISK-25034 #close
Reported by: Richard Mudgett

Change-Id: Ib8b17a438799920f4a2038826ff99a1884042f65

10 years agoMerge "res_pjsip_outbound_authenticator_digest: Add missing outbound authenticator...
Matt Jordan [Fri, 1 May 2015 11:55:55 +0000 (06:55 -0500)] 
Merge "res_pjsip_outbound_authenticator_digest: Add missing outbound authenticator callback." into certified/13.1

10 years agoPrevent potential crash on blond transfer. 23/323/1
Mark Michelson [Thu, 30 Apr 2015 20:20:43 +0000 (15:20 -0500)] 
Prevent potential crash on blond transfer.

Scenario:
Alice calls Bob. Bob performs a blond transfer to Carol. Carol rejects
the incoming call (or some other immediate circumstance causes Carol not
to answer the call)

What occurs in this case is that when the bridge between Alice and Bob
breaks, Alice is told to masquerade into Bob's channel that had placed
the call to Carol. The actual masquerade goes down without a hitch.
However, a channel fixup callback that attempts to publish dial events
over Stasis has a crash. The reason for this crash is that the datastore
on Bob's channel that placed the outbound call to Carol only had a bare
pointer to Carol's channel. Since Carol rejected the incoming call,
Carol's channel has been hung up and freed, meaning accessing her
channel results in a crash.

The fix here is simple. The dial fixup code has been altered to hold
references to the involved channels and to drop those references when
freeing data.

ASTERISK-25025 #close
Reported by Chet Stevens

Change-Id: I54eedda207b8ec7a69263353b43abe5746aea197

10 years agores_pjsip_outbound_authenticator_digest: Add missing outbound authenticator callback. 18/318/2
Mark Michelson [Thu, 30 Apr 2015 19:09:32 +0000 (14:09 -0500)] 
res_pjsip_outbound_authenticator_digest: Add missing outbound authenticator callback.

The Asterisk 13 version of the fix for outbound registration was missing
a key component that set the outbound authenticator's callback that
creates an authenticated request based on an old request. This was
picked up by some outbound registration tests failing in the testsuite.

Change-Id: I5ca9379698c606da36bc38eaffccedaf64211ce3

10 years agores_pjsip_outbound_registration: Fix double unref on error return. 08/308/1
Joshua Colp [Thu, 30 Apr 2015 11:04:34 +0000 (08:04 -0300)] 
res_pjsip_outbound_registration: Fix double unref on error return.

When the PJSIP pjsip_regc_send function is invoked and an error
status returned the caller currently decrements the reference count
of the client state that it just incremented, assuming the
registration callback would not have been invoked. In practice
this is not correct. If the failure happens after the transaction
has been set up the callback will still be invoked. This will
cause the reference count to be incorrectly decremented twice, once
by the registration callback and second by the caller of
pjsip_regc_send.

This change makes it so that whether the callback is invoked or
not is known by the caller of pjsip_regc_send. Depending on
this it can know whether it is responsible for decrementing the
reference count of the client state or not.

ASTERISK-25037 #close
Reported by: Joshua Colp

Change-Id: I749dc12f3a22115c49c5d7d95ff42a5fa45319de

10 years agores_pjsip_outbound_registration: Don't fail on delayed processing: 13. 98/298/2
Mark Michelson [Mon, 27 Apr 2015 21:56:31 +0000 (16:56 -0500)] 
res_pjsip_outbound_registration: Don't fail on delayed processing: 13.

This is the Asterisk 13 version of a change to master that allows for
registration responses to be processed successfully potentially after
the original transaction has timed out. The main difference between this
and the master change is that the master version has API changes that
are unacceptable for 13. For 13, this is worked around by adding a new
API call that the outbound registration code uses instead.

The following is the text from the master version of this commit:

Odd behaviors have been observed during outbound registrations. The most
common problem witnessed has been one where a request with
authentication credentials cannot be created after receiving a 401
response. Other behaviors include apparently processing an incorrect SIP
response.

Inspecting the code led to an apparent issue with regards to how we
handle transactions in outbound registration code. When a response to a
REGISTER arrives, we save a pointer to the transaction and then push a
task onto the registration serializer. Between the time that we save the
pointer and push the task, it's possible for the transaction to be
destroyed due to a timeout. It's also possible for the address to be
reused by the transaction layer for a new transaction.

To allow for authentication of a REGISTER request to be authenticated
after the transaction has timed out, we now also hold a reference to the
original REGISTER request instead of the transaction. The function for
creating a request with authentication has been altered to take the
original request instead of the transaction where the original request
was sent.

ASTERISK-25020
Reported by Mark Michelson

Change-Id: If1ee5f601be839479a219424f0358a229f358f7c

10 years agores_pjsip_outbound_registration: Add debugging messages. 97/297/1
Mark Michelson [Mon, 27 Apr 2015 19:44:16 +0000 (14:44 -0500)] 
res_pjsip_outbound_registration: Add debugging messages.

When problems occur regarding outbound registrations, it currently
is difficult to debug. Most off-nominal paths had warning messages,
but sometimes we want to know what's going on before hitting the
off-nominal path. This patch adds lots of debugging output that
should give a clearer picture of what is happening with regards
to outbound registrations.

ASTERISK-25020
Reported by Mark Michelson

Change-Id: I577bde7860be0a6c872b5bcb4d5047340bf45d45

10 years agoMerge "res_pjsip_t38: Don't crash on authenticated reinvite after originated T.38...
Matt Jordan [Fri, 24 Apr 2015 14:24:40 +0000 (09:24 -0500)] 
Merge "res_pjsip_t38: Don't crash on authenticated reinvite after originated T.38 FAX." into certified/13.1

10 years agores/res_pjsip_t38: Add missing initialization of t38faxmaxdatagram 39/239/1
Matthew Jordan [Sat, 11 Apr 2015 15:10:34 +0000 (15:10 +0000)] 
res/res_pjsip_t38: Add missing initialization of t38faxmaxdatagram

Prior to this patch, the far_max_datagram value on the UDPTL structure would
remain -1 if the remote endpoint fails to provide the SDP media attribute
T38FaxMaxDatagram. This can result in the INVITE request being rejected. With
this patch, we will now properly initialize the value with either the default
value or with the value provided by pjsip.conf's t38_udptl_maxdatagram
parameter.

Review: https://reviewboard.asterisk.org/r/4589

ASTERISK-24928 #close
Reported by: Juergen Spies
Tested by: Juergen Spies
patches:
  pjsipT38patch20150331.txt submitted by Juergen Spies (License 6698)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434688 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Change-Id: I15bde169fd59a224a02005fec9a439f0679a375e

10 years agores_pjsip_t38: Don't crash on authenticated reinvite after originated T.38 FAX. 38/238/3
Mark Michelson [Thu, 23 Apr 2015 17:54:30 +0000 (12:54 -0500)] 
res_pjsip_t38: Don't crash on authenticated reinvite after originated T.38 FAX.

When Asterisk originates a channel to an application, the channel is
hung up once the application finishes executing. When the application
in question is SendFax, the Asterisk PJSIP code will attempt to reinvite
the T.38 session to audio after the FAX completes. The hangup of the
channel happens in the midst of this reinvite transaction. In most
circumstances, this works out okay because the BYE is delayed until the
reinvite transaction can complete.

However, if the reinvite that Asterisk sends receives a 401/407
response, then Asterisk's attempt to re-send the reinvite with
authentication will fail. This is because the session supplement in
res_pjsip_t38 makes the assumption that the channel on the session will
always be non-NULL. Since the channel has been hung up, though, the
channel is now NULL. Attempting to operate on the channel causes a
crash.

This patch fixes the issue by ensuring that the channel on the session
is not NULL before attempting to mess with the T.38 framehook.

This patch also contains some corrections for comments that were
incorrect and really confused me when I first started looking at the
code.

ASTERISK-25004 #close
Reported by Mark Michelson

Change-Id: Ic5a1230668369dda4bb13524098aed9306ab45a0

10 years agoMerge topic 'certified-13.1' into certified/13.1
Joshua Colp [Wed, 22 Apr 2015 21:35:55 +0000 (16:35 -0500)] 
Merge topic 'certified-13.1' into certified/13.1

* changes:
  Detect potential forwarding loops based on count.
  More .gitignore updates
  .gitignore updates for master/13

10 years agoMerge "build_tools/make_version: Update version parsing for Git migration" into certi...
Mark Michelson [Wed, 22 Apr 2015 21:18:55 +0000 (16:18 -0500)] 
Merge "build_tools/make_version: Update version parsing for Git migration" into certified/13.1

10 years agoMerge "git migration: Remove support for file versions" into certified/13.1
Mark Michelson [Wed, 22 Apr 2015 21:18:38 +0000 (16:18 -0500)] 
Merge "git migration: Remove support for file versions" into certified/13.1

10 years agoMerge topic 'certified-13.1' into certified/13.1
Mark Michelson [Wed, 22 Apr 2015 21:17:39 +0000 (16:17 -0500)] 
Merge topic 'certified-13.1' into certified/13.1

* changes:
  main/editline: Add .gitignore.
  .gitignore: Ignore tarballs (*.gz)