Commit Graph

3218 Commits

Author SHA1 Message Date
Walter Doekes
8ce51a7b75 Ensure that string field lengths are properly aligned
Integers should always be aligned. For some platforms (ARM, SPARC) this
is more important than for others. This changeset ensures that the
string field string lengths are aligned on *all* platforms, not just on
the SPARC for which there was a workaround. It also fixes that the
length integer can be resized to 32 bits without problems if needed.

(closes issue ASTERISK-17310)
Reported by: radael, S Adrian
Reviewed by: Tzafrir Cohen, Terry Wilson
Tested by: S Adrian

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@343157 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-02 21:32:46 +00:00
Walter Doekes
ab2dacb555 Several fixes to the chan_sip dynamic realtime peer/user lookup
There were several problems with the dynamic realtime peer/user lookup
code. The lookup logic had become rather hard to read due to lots of
incremental changes to the realtime_peer function. And, during the
addition of the sipregs functionality, several possibilities for memory
leaks had been introduced. The insecure=port matching has always been
broken for anyone using the sipregs family. And, related, the broken
implementation forced those using sipregs to *still* have an ipaddr
column on their sippeers table.

Thanks Terry Wilson for comprehensive testing and finding and fixing
unexpected behaviour from the multientry realtime call which caused
the realtime_peer to have a completely unused code path.

This changeset fixes the leaks, the lookup inconsistenties and that
you won't need an ipaddr column on your sippeers table anymore (when
you're using sipregs). Beware that when you're using sipregs, peers
with insecure=port will now start matching!

(closes issue ASTERISK-17792)
(closes issue ASTERISK-18356)
Reported by: marcelloceschia, Walter Doekes
Reviewed by: Terry Wilson

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@342927 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-01 20:53:37 +00:00
Walter Doekes
68b523463d Cleanup references to sipusers and sipfriends dynamic realtime families
Somewhere between 1.4 and 1.8 the sipusers family has become completely
unused. Before that, the sipfriends family had been obsoleted in favor
of separate sipusers and sippeers families. Apparently, they have been
merged back again into a single family which is now called "sippeers".

Reviewed by: irroot, oej, pabelanger

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@342869 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-01 19:37:47 +00:00
Matthew Jordan
8765a80355 Fixed invalid memory access when adding extension to pattern match tree
When an extension is removed from a context, its entry in the pattern match
tree is not deleted.  Instead, the extension is marked as deleted.  When an
extension is removed and re-added, if that extension is also a prefix of
another extension, several log messages would report an error and did not
check whether or not the extension was deleted before accessing the memory.
Additionally, if the extension was already in the tree but previously
deleted, and the pattern was at the end of a match, the findonly flag was
not honored and the extension would be erroneously undeleted.  

Additionaly, it was discovered that an IAX2 peer could be unregistered
via the CLI, while at the same time it could be scheduled for unregistration
by Asterisk.  The unregistration method now checks to see if the peer
was already unregistered before continuing with an unregistration.

(closes issue ASTERISK-18135)
Reported by: Jaco Kroon, Henry Fernandes, Kristijan Vrban
Tested by: Matt Jordan

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




git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@342769 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-31 15:58:06 +00:00
Richard Mudgett
d109a3973b Check fopen return value for ao2 reference debug output.
Reported by: wdoekes
Patched by: wdoekes

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@342487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-25 22:04:59 +00:00
Terry Wilson
a98dd1933b Return NULL when no results returned for realtime_multientry
It was not documented what the return value should be when no entries
were returned with the multientry realtime callback. This change forces
consistent behavior even if the backends return an empty ast_config.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@342223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-25 01:23:29 +00:00
Richard Mudgett
dbacd97e17 Fix AGI exec Park to honor the Park application parameters.
The fix for ASTERISK-12715 and ASTERISK-12685 added a check for the Park
application because the channel needed to be masqueraded to prevent a
crash.  Since the Park application now always masquerades the channel into
the parking lot, the special check is no longer needed.  The fix also
resulted in AGI exec Park attempting to double park the call and not honor
the Park application parameters.

* Removed no longer necessary call to ast_masq_park_call() by AGI exec for
the Park application.  (Reverts -r146923)

* Fix Park application to only return 0 or -1.  The AGI exec Park was
causing broken pipe error messages because the Park application returned 1
on successful park.

(closes issue ASTERISK-18737)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@341717 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-20 21:54:11 +00:00
Richard Mudgett
f2b371fedf More parking issues.
* Fix potential deadlocks in SIP and IAX blind transfer to parking.

* Fix SIP, IAX, DAHDI analog, and MGCP channel drivers to respect the
parkext_exclusive option with transfers (Park(,,,,,exclusive_lot)
parameter).  Created ast_park_call_exten() and ast_masq_park_call_exten()
to maintian API compatibility.

* Made masq_park_call() handle a failed ast_channel_masquerade() setup.

* Reduced excessive struct parkeduser.peername[] size.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@341254 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-18 21:03:04 +00:00
Terry Wilson
927336fe2f Avoid unnecessary WARNING message
Add AST_CONTROL_UPDATE_RTP_PEER frame to be ignored here to avoid
displaying a WARNING message.

(closes issue ASTERISK-18610)
 Patch by: Kristijan_Vrban


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@340878 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-14 16:33:28 +00:00
Richard Mudgett
85c808bfc4 Fix DTMF blind transfer continuing to execute dialplan after transfer.
Party A calls Party B.
Party A DTMF blind transfers Party B to Party C.
Party A channel continues to execute dialplan.

* Fixed the return value of builtin_blindtransfer() to return the correct
value after a transfer so the dialplan will not keep executing.

* Removed unnecessary connected line update that did not really do
anything.

* Made access to GOTO_ON_BLINDXFR thread safe in check_goto_on_transfer().

* Fixed leak of xferchan for failure cases in check_goto_on_transfer().

* Updated debug messages in builtin_blindtransfer() and
check_goto_on_transfer().

(closes issue ASTERISK-18275)
Reported by: rmudgett
Tested by: rmudgett


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@340809 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-13 22:48:58 +00:00
Richard Mudgett
236637104d Convert registered AMI actions to ao2 objects.
* Fixed race between calling an AMI action callback and unregistering that
action.  Refixes ASTERISK-13784 broken by ASTERISK-17785 change.

* Fixed potential memory leak if an AMI action failed to get registered
because is already was registered.  Part of the ao2 conversion.

* Fixed AMI ListCommands action not walking the actions list with a lock
held.

* Fix usage of ast_strdupa() and alloca() in loops.  Excess stack usage.

* Fix AMI Originate action Variable header requiring a space after the
header colon.  Reported by Yaroslav Panych on the asterisk-dev list.

* Increased the number of listed variables allowed per AMI Originate
action Variable header to 64.

* Fixed AMI GetConfigJSON action output format.

* Fixed usage of res contents outside of scope in append_channel_vars().

* Fixed inconsistency of config file channelvars option.  The values no
longer accumulate with every channelvars option in the config file.  Only
the last value is kept to be consistent with the CLI "manager show
settings" command.

(closes issue ASTERISK-18479)
Reported by: Jaco Kroon


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@340279 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-11 18:23:14 +00:00
Tzafrir Cohen
9a426fab4d Update SHA1 code to RFC 6234
RFC 6234 is an update to RFC 3174 from which the code was originally taken.
It has a slightly better code, and a better phrased license (simple 3-clause
BSD).

* main/sha1.c is sha1.c from RFC 6234 with formatting changes only.
* include/asterisk/sha1.h merges sha.h and sha-private.h from RFC 6234.
* Removed unused include of asterisk/sha1.h from main/channels.c

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@340263 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-11 00:43:14 +00:00
Matthew Nicholson
de9e8e501e Load the proper XML documentation when multiple modules document the same application.
This patch adds an optional "module" attribute to the XML documentation spec
that allows the documentation processor to match apps with identical names from
different modules to their documentation. This patch also fixes a number of
bugs with the documentation processor and should make it a little more
efficient. Support for multiple languages has also been properly implemented.

ASTERISK-18130
Review: https://reviewboard.asterisk.org/r/1485/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@340108 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-10 14:14:48 +00:00
Richard Mudgett
06e6b7bba1 Fix debugging messages generated by 'udptl debug'.
* Makes chan_sip set the tag to the channel name.

* Fixes received debug message sequence number.

* Removed tx/rx debug message type since it was hard coded to 0.

* Made udptl.c logged message header consistent if possible: "UDPTL (%s): ".

* Removed unused rx_expected_seq_no from struct ast_udptl.

(closes issue ASTERISK-18401)
Reported by: Kevin P. Fleming
Patches:
      jira_asterisk_18401_v1.8.patch (license #5621) patch uploaded by rmudgett
Tested by: Matthew Nicholson


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@339625 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-06 17:49:38 +00:00
Richard Mudgett
75f2105a48 Fix XML error in AMI action Challenge.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@339506 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-05 16:32:03 +00:00
Richard Mudgett
03a7359585 Add missing documentation of required AMI action Challenge AuthType header.
(closes issue ASTERISK-18554)
Reported by: Vlad Povorozniuc
Patches:
      __20110919-manager-challenge-docs.patch.txt (license #4999) patch uploaded by Leif Madsen


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@339504 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-05 16:26:45 +00:00
Jonathan Rose
48f0916a44 Removes improper use of sound 'and' in German language mode from application saynumber
Asterisk would say 'Five hundert und sechs und zwanzig' instead of 'Five hundert sechs
und zwanzig'... which is both weird sounding and wrong.  This patch makes sure Asterisk
will only say the 'and' word between the single digit and double digit places.

(closes issue ASTERISK-18212)
Reported By: Lionel Elie Mamane
Patches:
	upstream_germand_no_and.diff (License #5402) uploaded by Lionel Elie Mamane



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@339352 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-04 19:33:12 +00:00
Terry Wilson
a0eb30ea43 Properly ignore AST_CONTROL_UPDATE_RTP_PEER in more places
After the change in r336294, the new AST_CONTROL_UPDATE_RTP_PEER frame
is sent when a re-invite happens. If we receive a re-invite from a device
the waitstream_core was not aware of the new control frame and would drop
the call.

(closes issue ASTERISK-18610)
	Reported by: Kristijan_Vrban


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@339086 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-10-03 18:40:52 +00:00
Richard Mudgett
f2e1640435 Fix deadlock when using dummy channels.
Dummy channels created by ast_dummy_channel_alloc() should be destoyed by
ast_channel_unref().  Using ast_channel_release() needlessly grabs the
channel container lock and can cause a deadlock as a result.

* Analyzed use of ast_dummy_channel_alloc() and made use
ast_channel_unref() when done with the dummy channel.  (Primary reason for
the reported deadlock.)

* Made app_dial.c:dial_exec_full() not call ast_call() holding any channel
locks.  Chan_local could not perform deadlock avoidance correctly.
(Potential deadlock exposed by this issue.  Secondary reason for the
reported deadlock since the held lock was part of the deadlock chain.)

* Fixed some uses of ast_dummy_channel_alloc() not checking the returned
channel pointer for failure.

* Fixed some potential chan=NULL pointer usage in func_odbc.c.  Protected
by testing the bogus_chan value.

* Fixed needlessly clearing a 1024 char auto array when setting the first
char to zero is enough in manager.c:action_getvar().

(closes issue ASTERISK-18613)
Reported by: Thomas Arimont
Patches:
      jira_asterisk_18613_v1.8.patch (license #5621) patch uploaded by rmudgett
Tested by: Thomas Arimont


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@337973 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-26 19:30:39 +00:00
Gregory Nietsky
c47fd8f774 Its possible to loose audio on ast_write when the channel is not transcoded correctly.
in the case of DAHDI the channel is hungup.

This patch tries to "fix" the problem and make the channel compatiable and warn the user of
this problem.

Please note there is a underlying problem with codec negotion this does not fix the problem
it does try to rectify it and prevent loss of service.

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

(closes issue ASTERISK-17541)
(closes issue ASTERISK-18063)
(issue ASTERISK-14384)
(issue ASTERISK-17502)
(issue ASTERISK-18325)
(issue ASTERISK-18422)



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@337430 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-22 06:18:33 +00:00
Matthew Jordan
f13c3b3fd2 Fix for incorrect voicemail duration in external notifications
This patch fixes an issue where the voicemail duration was being reported
with a duration significantly less than the actual sound file duration.
Voicemails that contained mostly silence were reporting the duration of
only the sound in the file, as opposed to the duration of the file with
the silence.  This patch fixes this by having two durations reported in
the __ast_play_and_record family of functions - the sound_duration and the
actual duration of the file.  The sound_duration, which is optional, now
reports the duration of the sound in the file, while the actual full duration
of the file is reported in the duration parameter.  This allows the voicemail
applications to use the sound_duration for minimum duration checking, while
reporting the full duration to external parties if the voicemail is kept.

(issue ASTERISK-2234)
(closes issue ASTERISK-16981)
Reported by: Mary Ciuciu, Byron Clark, Brad House, Karsten Wemheuer, KevinH
Tested by: Matt Jordan

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@337118 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-20 22:38:54 +00:00
Kinsey Moore
8a0b9d39e5 Make CANMATCH with the new pattern match engine behave more like the old one
When checking an extension for E_CANMATCH using the new extension matching
algorithm, an exact match was not returned as a possible match resulting in the
queue failing to allow a caller to exit on DTMF.  This removes the requirement
that an extension be longer than acquired digits for an E_CANMATCH operation
to succeed.

(closes issue ASTERISK-18044)
Review: https://reviewboard.asterisk.org/r/1367/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@337061 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-20 21:04:11 +00:00
Tilghman Lesher
02795f190e Various changes to allow 1.8 to compile on Mac OS X Lion (10.7)
* Makefile workaround for 10.6 extended to work on 10.7 and later.
* Now uses the 'weak' symbol for Lion systems, which no longer support
  'weak_import'

Closes ASTERISK-17612.
Closes ASTERISK-18213.

Tested by: tilghman, oej.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@336733 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-19 20:27:03 +00:00
Olle Johansson
02a28f4afe Make sure manager_debug option is reset at reload
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@336440 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-19 12:06:48 +00:00
Jonathan Rose
21714a05b6 Fix bad RTP media bridges in directmedia calls on peers separated by multiple Asterisk nodes.
In a situation involving devices on separate Asterisk trunks, the remote RTP bridge would
break when starting a call with directmedia. This patch queues a new type of control frame
so that our RTP bridge loop can properly detect when these situations occur and check to see
if peers need to be updated in order to send their media to the proper location.

(Closes issue ASTERISK-18340)
Reported by: Thomas Arimont
(Closes issue ASTERISK-17725)
Reported by: kwk
Tested by: twilson, jrose


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@336294 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-16 19:53:40 +00:00
Matthew Nicholson
454969d783 The tech and data members of fast_originate_helper are not string fields.
ASTERISK-17709


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@335790 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-14 13:28:16 +00:00
Tzafrir Cohen
42840a2ef9 do parse defaultlanguage from asterisk.conf
Do parse the option "defaultlanguage" from the [options] section of
asterisk.conf, as in the sample config file. Otherwise the build-time
default language (normally "en") is always the default one.

Review: https://reviewboard.asterisk.org/r/1342/
Signed-off-by: Tzafrir Cohen (License #5035) <tzafrir.cohen@xorcom.com>

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@335716 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-13 21:33:20 +00:00
Matthew Nicholson
ebb6110a13 Don't limit the size of appdata for manager originate actions.
ASTERISK-17709
Patch by: tilghman (with modifications)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@335618 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-13 18:20:52 +00:00
Russell Bryant
5f1882731a Fix a crash in res_ais.
This patch resolves a crash observed in a load testing environment that
involved the use of the res_ais module.  I observed some crashes where
the event delivery callback would get called, but the length parameter
incidcating how much data there was to read was 0.  The code assumed
(with good reason I would think) that if this callback got called, there
was an event available to read.  However, if the rare case that there's
nothing there, catch it and return instead of blowing up.

More specifically, the change always ensure that the size of the received
event in the cluster is always big enough to be a real ast_event.

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@335497 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-13 07:11:36 +00:00
Matthew Nicholson
1aeb6f1242 Properly set caller_warning and callee_warning before we try to use them.
ASTERISK-18199
Patch by: elguero
Testing by: rtang


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@335433 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-12 15:54:41 +00:00
Matthew Jordan
7dc49195d8 Updated SIP 484 handling; added Incomplete control frame
When a SIP phone uses the dial application and receives a 484 Address 
Incomplete response, if overlapped dialing is enabled for SIP, then
the 484 Address Incomplete is forwarded back to the SIP phone and the
HANGUPCAUSE channel variable is set to 28.  Previously, the Incomplete
application dialplan logic was automatically triggered; now, explicit
dialplan usage of the application is required.

Additionally, this patch adds a new AST_CONTOL_FRAME type called
AST_CONTROL_INCOMPLETE.  If a channel driver receives this control frame,
it is an indication that the dialplan expects more digits back from the
device.  If the device supports overlap dialing it should attempt to 
notify the device that the dialplan is waiting for more digits; otherwise,
it can handle the frame in a manner appropriate to the channel driver.

(closes issue ASTERISK-17288)
Reported by: Mikael Carlsson
Tested by: Matthew Jordan

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



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@335064 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-09 16:09:09 +00:00
Richard Mudgett
2fb25c3aea Fix crash with res_fax when MALLOC_DEBUG and "core stop gracefully" are used.
Asterisk crashes if MALLOC_DEBUG is enabled when res_fax tries to
unregister its logger level.

* Make ast_logger_unregister_level() use ast_free() instead of free().
When MALLOC_DEBUG is enabled, ast_free() does not degenerate into a call
to free().  Therefore, if you allocated memory with a form of ast_malloc
you must free it with ast_free.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@334953 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-08 22:27:40 +00:00
Richard Mudgett
c6e7f17a68 Fix AMI action Park crash.
* Made AMI action Park not say anything to the parker channel (AMI header
Channel2) since the AMI action is a third party parking the call.  (This
is a change in behavior that cannot be preserved without a lot of effort.)

* Made not play pbx-parkingfailed if the Park 's' option is used.

JIRA AST-660


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@334840 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-07 19:31:44 +00:00
Stefan Schmidt
687e413fd8 Adding the Feature to sent a Reason Header in a SIP Cancel message by set the flag AST_FLAG_ANSWERED_ELSEWHERE before doing a masquerade in the pickup function.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@334682 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-07 13:26:50 +00:00
Alec L Davis
71f3dc01da Prevent segfault if call arrives before Asterisk is fully booted.
Prevent ast_pbx_start and ast_run_start from starting a new thread unless asterisk
is fully booted.
 
alecdavis (license 585)
Tested by: alecdavis
 
Review: https://reviewboard.asterisk.org/r/1407/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@334616 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-07 07:33:39 +00:00
Richard Mudgett
6d49117675 Fix potential memory allocation failure crashes in config.c.
* Added required checks to the returned memory allocation pointers to
prevent crashes.

* Made ast_include_rename() create a replacement ast_variable list node if
the new filename is longer than the available space.  Fixes potential
crash and memory leak.

* Factored out ast_variable_move() from ast_variable_update() so
ast_include_rename() can also use it when creating a replacement
ast_variable list node.

* Made the filename stuffed at the end of the struct a minimum allocated
size in ast_variable_new() in case ast_include_rename() changes the stored
filename.

* Constify struct char pointers pointing to strings stuffed at the end of
the struct for: ast_variable, cache_file_mtime, and ast_config_map.

* Factored out cfmtime_new() to remove inlined code and allow some struct
pointers to become const.

* Removed the list lock from struct cache_file_mtime that was never used.

* Added doxygen comments to several structure elements and better
documented what strings are stuffed at the struct end char array.

* Reworked ast_config_text_file_save() and set_fn() to handle allocation
failure of the include file scratch pad object tracking blank lines.

* Made ast_config_text_file_save() fn[] declared with PATH_MAX to ensure
it is long enough for any filename with path.  Also reduced the number of
container fileset buckets from a rediculus 180,000 to 1023.

JIRA AST-618

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@334296 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-02 17:10:58 +00:00
Tilghman Lesher
b178214e07 Remove 1.6 compatibility documentation from 1.8, as it no longer applies.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@334234 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-09-01 17:38:33 +00:00
Richard Mudgett
9e99b1819e Call pickup race leaves orphaned channels or crashes.
Multiple users attempting to pickup a call that has been forked to
multiple extensions either crashes or fails a masquerade with a "bad
things may happen" message.

This is the scenario that is causing all the grief:
1) Pickup target is selected
2) target is marked as being picked up in ast_do_pickup()
3) target is unlocked by ast_do_pickup()
4) app dial or queue gets a chance to hang up losing calls and calls
ast_hangup() on target
5) SINCE A MASQUERADE HAS NOT BEEN SETUP YET BY ast_do_pickup() with
ast_channel_masquerade(), ast_hangup() completes successfully and the
channel is no longer in the channels container.
6) ast_do_pickup() then calls ast_channel_masquerade() to schedule the
masquerade on the dead channel.
7) ast_do_pickup() then calls ast_do_masquerade() on the dead channel
8) bad things happen while doing the masquerade and in the process
ast_do_masquerade() puts the dead channel back into the channels container
9) The "orphaned" channel is visible in the channels list if a crash does
not happen.

This patch does the following:

* Made ast_hangup() set AST_FLAG_ZOMBIE on a successfully hung-up channel
and not release the channel lock until that has happened.

* Made __ast_channel_masquerade() not setup a masquerade if either channel
has AST_FLAG_ZOMBIE set.

* Fix chan_agent misuse of AST_FLAG_ZOMBIE since it would no longer work.

(closes issue ASTERISK-18222)
Reported by: Alec Davis
Tested by: rmudgett, Alec Davis, irroot, Karsten Wemheuer

(closes issue ASTERISK-18273)
Reported by: Karsten Wemheuer
Tested by: rmudgett, Alec Davis, irroot, Karsten Wemheuer

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@334009 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-31 15:20:31 +00:00
Richard Mudgett
b1f11e0df4 Revert previous commit. Not ready yet.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@332945 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-22 22:11:54 +00:00
Richard Mudgett
c0ce03d77f Signed
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@332943 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-22 22:02:52 +00:00
Richard Mudgett
b06b8acd20 Minor code optimizations.
* Simplify ast_category_browse() logic for easier understanding.

* Remove dead code in ast_variable_delete() and simplify some of its
logic.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@332939 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-22 21:22:24 +00:00
Matthew Jordan
56549c96ab Review: https://reviewboard.asterisk.org/r/1364/
This update adds a new AMI event, TestEvent, which is enabled when the TEST_FRAMEWORK compiler flag is defined.  It also adds initial usage of this event to app_voicemail.  The TestEvent AMI event is used extensively by the voicemail tests in the Asterisk Test Suite.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@332817 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-22 18:15:51 +00:00
Richard Mudgett
08b76290a2 Memory leak reading realtime database variable list.
Calling ast_load_realtime() can leak the last list node if the read list
only contains empty variable value items.

* Fixed list filter loop in ast_load_realtime() to delete the list node
immediately instead of the next time through the loop.  The next time
through the loop may not happen if the node to delete is the last in the
list.

(issue ASTERISK-18277)
(issue ASTERISK-18265)
Patches:
      jira_asterisk_18265_v1.8_config.patch (license #5621) patch uploaded by rmudgett


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@332759 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-22 17:00:03 +00:00
Terry Wilson
5dd7370c32 Fix possible error on stringification of IPv4-mapped addrs
The FreeBSD netsock2 test has been failing for a while. We were
pasing sa->len to getnameinfo instead of sa_tmp->len.

ASTERISK-18289


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@332559 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-18 21:26:01 +00:00
Richard Mudgett
422e191e03 Fix multiple parking issues.
JIRA ASTERISK-17183
Multi-parkinglot directs calls to wrong parkinglot.
JIRA ASTERISK-17870
Cannot retrieve parked calls.
JIRA ASTERISK-17430
ParkedCall() with no extension should pickup first available call and does not.
JIRA AST-576
Issues with parking lots

* Removed searching for parking lots by extension.  Parking lots can only
be found by the parking lot name since parking lot access extensions and
spaces are not guaranteed to be unique.

* Added parking_lot_name option to the Park and ParkedCall applications.
Updated documentation for Park and ParkedCall applications.

* Add parkext_exclusive configuration option to make parking entry
extensions specify which parking lot they access.

(closes issue ASTERISK-17183)
Reported by: David Cabrejos
Tested by: rmudgett, David Cabrejos

(closes issue ASTERISK-17870)
Reported by: Remi Quezada

(closes issue ASTERISK-17430)
Reported by: Philippe Lindheimer


JIRA ASTERISK-17452
Parking_offset not used
JIRA AST-624
'next' setting for findslot does nothing

* Reimplemented since findslot feature option broken by -r114655.

(closes issue ASTERISK-17452)
Reported by: David Woolley
Tested by: rmudgett


JIRA ASTERISK-15792
Dialplan continues execution after transfer to park.

This happens for DTMF attended transfer, DTMF blind transfer, and DTMF
one-touch-parking if the party initiating these features also initiated
the call.

* Fixed the return code from the affected builtin features when parking a
call.

(closes issue ASTERISK-15792)
Reported by: Mat Murdock
Tested by: rmudgett, twilson


JIRA AST-607
The courtesytone is not playing to the expected call when picking up a
parked call.

This is mostly a documentation problem.  However, the option is not reset
to the default when features.conf is reloaded.

* Updated features.conf.sample documentation for courtesytone and
parkedplay options.

* Reset the parkedplay option to default when features.conf is reloaded.


JIRA AST-615
AMI Park action followed by features reload results in orphaned channels
in parking lot.

* Reloading features.conf will not touch parking lots that have calls
still parked in them.  Reload again at a later time.


Misc additional fixes:

* Added unit test for parking lot dialplan usage checking.

* Made update connected line when a parked call is retrieved from a
parking lot.

* Made retrieved parked call stop ringing or MOH depending upon how the
call was waiting in the parking lot.

* Made CLI "features show" indicate if the parking lot is enabled for use.

* Added PARKINGDYNEXTEN channel variable to allow dynamic parking lots to
specify the parking lot access extension.

* Made AMI ParkedCalls action ParkedCall events have a Parkinglot header.

* Made AMI ParkedCalls action ParkedCallsComplete event have a Total
header.

* Fixed potential deadlock from AMI Park action holding channel locks
while calling masq_park_call().

* Fixed several places where ast_strdupa() were used inside of loops.
(Mostly fixed by refactoring the loop body into its own function.)

* Fixed copy_parkinglot() copying too much from the source parking lot.
Extracted the parking lot configuration settings into struct
parkinglot_cfg.

* Refactored courtesytone playing code to put the channel not playing the
tone in autoservice.

* Fix when pbx-parkingfailed is played that the other channel is put in
autoservice if it exists.

* Fixed parkinglot reference leak in parked_call_exec() error paths.

* Fixed parkinglot_unref() use of parkinglot after it was unreffed.

* Made destroy the struct ast_parkinglot parkings lock when done.

* Refactored the features.conf parking lot configuration code to eliminate
redundancy.

* Fixed feature reload to better protect parking lots.

* Fixed parking lot container reference leak in handle_parkedcalls().

* Fixed the total count in handle_parkedcalls().

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@332100 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-16 16:31:36 +00:00
Paul Belanger
0281f945c0 Fix noisy message when briding channels
(closes issue ASTERISK-18270)
Reported by: Federico Alves


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@331886 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-15 15:21:16 +00:00
Kinsey Moore
173818cf8f Logger does not warn of failure to open logging channels
Currently, logger only prints an error message to stderr when it fails to open
a logger channel where many users will not see it because the logger lock is
held.  The alternative provided by this patch is to log the error to all
attached consoles in the hopes that it will be easier to see.  Additionally,
this patch prevents the failed logger channel from being added to the list
where it would silently fail on each call to the Asterisk logger.

(closes issue ASTERISK-16231)
Review: https://reviewboard.asterisk.org/r/1338


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@331649 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-12 16:20:25 +00:00
Richard Mudgett
e6b7737ef6 Output of queue log not started until logger reloaded.
ASTERISK-15863 caused a regression with queue logging.  The output of the
queue log is not started until the logger configuration is reloaded.

* Queue log initialization is completely delayed until the first message
is posted to the queue log system.  Including the initial opening of the
queue log file.

* Fixed rotate_file() ROTATE strategy to give the file just rotated out to
the configured exec function after rotate.  Just like the other strategies.

* Fixed logger reload to always post the queue reload entry instead of
just if there is a queue log file.

* Refactored some code to eliminate some redundancy and to reduce stack
utilization.

(closes issue ASTERISK-17036)
JIRA SWP-2952
Reported by: Juan Carlos Valero
Patches:
      jira_asterisk_17036_v1.8.patch (license #5621) patch uploaded by rmudgett
Tested by: rmudgett

(closes issue ASTERISK-18208)
Reported by: Christian Pinedo

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@331461 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-10 20:29:59 +00:00
Kinsey Moore
43a5273659 AMI action ModuleReload returns Error if Module: missing or empty
An empty string was not being checked for properly causing identification of
the module to be reloaded to fail and return an Error with message
"No such module."

(closes issue AST-616)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@331315 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-10 13:47:46 +00:00
Richard Mudgett
42b5040b71 Misc minor items found in code.
* Add some reentrancy protection in pbx.c when creating the contexts_table
hash table.

* Fix inverted test in chan_sip.c conditional code.

* Fix uninitialized variable and use of the wrong variable in chan_iax2.c.

* Fix test of return value in app_parkandannounce.c.  Explicitly testing
for -1 is bad if the function does not actually return that value when it
fails.

* Fixup some comments and add some curly braces in features.c.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@331248 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-08-09 22:12:59 +00:00