Commit Graph

34355 Commits

Author SHA1 Message Date
phoneben
e9fc5b041f app_queue: Fix rN raise_penalty ignoring min_penalty in calc_metric
QUEUE_RAISE_PENALTY=rN was not respected during member selection. calc_metric() raised penalties below QUEUE_MIN_PENALTY, allowing excluded members to be selected.

This change makes calc_metric() honor raise_respect_min, keeping behavior consistent with queue empty checks and expected rN semantics

UserNote: Fixes an issue where QUEUE_RAISE_PENALTY=rN could raise a member’s penalty below QUEUE_MIN_PENALTY during member selection. This could allow members intended to be excluded to be selected. The queue now consistently respects the minimum penalty when raising penalties, aligning member selection behavior with queue empty checks and documented rN semantics.
2026-03-26 19:23:12 +00:00
serfreeman1337
e9a41c6582 app_queue: Only compare calls at 1st position across queues when forcing longest waiting caller.
This prevents a situation where a call joining at 1st position to a queue with calls
leads to a state where no callers are considered the longest waiting,
causing queues to stop offering calls.

Resolves: #1691
2026-03-26 19:23:12 +00:00
Jasper Hafkenscheid
46dfa0fe1b channelstorage_cpp_map_name_id: Fix get_by_name_prefix prefix match
Lower bound filter did not ensure prefix match.

Resolves: #1730
2026-03-26 19:23:12 +00:00
George Joseph
07cd92b394 app_amd: Remove errant space in documentation for totalAnalysisTime. 2026-03-26 19:23:12 +00:00
Talha Asghar
8efcc1324d say.c: added language support for pashto and dari
With this new feature, users who speak these languages can now benefit from the
text-to-speech functionality provided by asterisk. This will make the platform
more accessible and useful to a wider range of users, particularly those in
regions where Pashto and Dari are spoken. This contribution will help to improve
the overall usability and inclusivity of the asterisk platform.

Fixes: #1724
2026-03-26 19:23:12 +00:00
hishamway
9aa763f260 res_pjsip_session.c: Prevent INVITE failover when session is cancelled
When an outbound INVITE transaction times out (408) or receives a 503 error,
check_request_status() attempts to failover to the next available address by
restarting the INVITE session. However, the function did not check if the
inv_session was already cancelled before attempting the failover.

This caused unexpected behavior when a caller hung up during a ring group
scenario: after CANCEL was sent but the remote endpoint failed to respond
with 487 (e.g., due to network disconnection), the transaction timeout
would trigger a NEW outbound INVITE to the next address, even though the
session was already terminated.

This violates RFC 3261 Section 9.1 which states that if no final response
is received after CANCEL within 64*T1 seconds, the client should consider
the transaction cancelled and destroy it, not retry to another address.

The fix adds a check for both PJSIP_INV_STATE_DISCONNECTED and inv->cancelling
at the beginning of check_request_status(). This ensures that:
- Failover is blocked when the user explicitly cancelled the call (CANCEL sent)
- Failover is still allowed for legitimate timeout/503 scenarios where no
  CANCEL was initiated (e.g., SRV failover when first server is unreachable)

Resolves: #1716
2026-03-26 19:23:12 +00:00
Alexei Gradinari
28543516c7 res_pjsip_pubsub: Fix ao2 reference leak of subscription tree in ast_sip_subscription
allocate_subscription() increments the ao2 reference count of the subscription tree,
but the reference was not consistently released during subscription destruction,
resulting in leaked sip_subscription_tree objects.

This patch makes destroy_subscription() responsible for releasing sub->tree,
removes ad-hoc cleanup in error paths,
and guards tree cleanup to ensure refcount symmetry and correct ownership.

Fixes: #1703
2026-03-26 19:23:12 +00:00
Asterisk Development Team
d49c5d454f Update for 20.18.2 20.18.2 2026-02-05 16:48:37 +00:00
George Joseph
640677c9d8 xml.c: Replace XML_PARSE_NOENT with XML_PARSE_NONET for xmlReadFile.
The xmlReadFile XML_PARSE_NOENT flag, which allows parsing of external
entities, could allow a potential XXE injection attack.  Replacing it with
XML_PARSE_NONET, which prevents network access, is safer.

Resolves: #GHSA-85x7-54wr-vh42
2026-02-05 08:39:44 -07:00
Mike Bradeen
dc5e7418a3 ast_coredumper: check ast_debug_tools.conf permissions
Prevent ast_coredumper from using ast_debug_tools.conf files that are
not owned by root or are writable by other users or groups.

Prevent ast_logescalator and ast_loggrabber from doing the same if
they are run as root.

Resolves: #GHSA-rvch-3jmx-3jf3

UserNote: ast_debug_tools.conf must be owned by root and not be
writable by other users or groups to be used by ast_coredumper or
by ast_logescalator or ast_loggrabber when run as root.
2026-02-05 08:39:44 -07:00
George Joseph
444be00e05 http.c: Change httpstatus to default disabled and sanitize output.
To address potential security issues, the httpstatus page is now disabled
by default and the echoed query string and cookie output is html-escaped.

Resolves: #GHSA-v6hp-wh3r-cwxh

UpgradeNote: To prevent possible security issues, the `/httpstatus` page
served by the internal web server is now disabled by default.  To explicitly
enable it, set `enable_status=yes` in http.conf.
2026-02-05 08:39:44 -07:00
Mike Bradeen
97d3df9cf7 ast_coredumper: create gdbinit file with restrictive permissions
Modify gdbinit to use the install command with explicit permissions (-m 600)
when creating the .ast_coredumper.gdbinit file. This ensures the file is
created with restricted permissions (readable/writable only by the owner)
to avoid potential privilege escalation.

Resolves: #GHSA-xpc6-x892-v83c
2026-02-05 08:39:44 -07:00
Asterisk Development Team
1008662095 Update for 20.18.1 20.18.1 2026-01-29 14:26:56 +00:00
Sean Bright
d993d8a21d asterisk.c: Use C.UTF-8 locale instead of relying on user's environment.
Resolves: #1739
2026-01-29 07:03:22 -07:00
Asterisk Development Team
b33a6460ec Update for 20.18.0 20.18.0 2026-01-22 16:50:57 +00:00
George Joseph
57b601e270 chan_websocket.conf.sample: Fix category name.
UserNote: The category name in the chan_websocket.conf.sample file was
incorrect.  It should be "global" instead of "general".
2026-01-21 14:37:17 -07:00
Asterisk Development Team
cb0248a2e7 Update for 20.18.0-rc1 20.18.0-rc1 2026-01-15 16:55:03 +00:00
Joe Garlick
aa1d725d70 chan_websocket: Fixed Ping/Pong messages hanging up the websocket channel
When chan_websocket received a Ping or a Pong opcode it would cause the channel to hangup. This change allows Ping/Pong opcodes and allows them to silently pass
2026-01-15 16:47:32 +00:00
Sean Bright
b767e71c5a cli.c: Allow 'channel request hangup' to accept patterns.
This extends 'channel request hangup' to accept multiple channel
names, a POSIX Extended Regular Expression, a glob-like pattern, or a
combination of all of them.

UserNote: The 'channel request hangup' CLI command now accepts
multiple channel names, POSIX Extended Regular Expressions, glob-like
patterns, or a combination of all of them. See the CLI command 'core
show help channel request hangup' for full details.
2026-01-15 16:47:32 +00:00
Etienne Lessard
75878a1e8d chan_sip.c: Ensure Contact header is set on responses to INVITE.
From the original report* on ASTERISK-24915:

  > The problem occurs because the handle_incoming function updates
  p->method to req->method (p being a struct sip_pvt *) before
  checking if the CSeq makes sense, and if the CSeq is unexpected, it
  does not reset p->method to its old value before returning. Then,
  when asterisk sends the 200 OK response for the original INVITE,
  since p->method is now equal to SIP_ACK (instead of SIP_INVITE), the
  resp_need_contact function (called from respprep) says "its a SIP
  ACK, no need to add a Contact header for the response", which is
  wrong, since it's not a SIP ACK but a SIP INVITE dialog.

I have confirmed that the analysis is correct and that the patch fixes
the behavior.

*: https://issues-archive.asterisk.org/ASTERISK-24915

Resolves: #1711
2026-01-15 16:47:32 +00:00
Mike Bradeen
0ab029d9cf res_sorcery_memory_cache: Reduce cache lock time for sorcery memory cache populate command
Reduce cache lock time for AMI and CLI sorcery memory cache populate
commands by adding a new populate_lock to the sorcery_memory_cache
struct which is locked separately from the existing cache lock so that
the cache lock can be maintained for a reduced time, locking only when
the cache objects are removed and re-populated.

Resolves: #1700

UserNote: The AMI command sorcery memory cache populate will now
return an error if there is an internal error performing the populate.
The CLI command will display an error in this case as well.
2026-01-15 16:47:32 +00:00
phoneben
6abb213afd Add comment to asterisk.conf.sample clarifying that template sections are ignored
Add comment to asterisk.conf.sample clarifying that template sections are ignored.

Resolves: #1692
2026-01-15 16:47:31 +00:00
George Joseph
e6f5a091bf chan_websocket: Use the channel's ability to poll fds for the websocket read.
We now add the websocket's file descriptor to the channel's fd array and let
it poll for data availability instead if having a dedicated thread that
does the polling. This eliminates the thread and allows removal of most
explicit locking since the core channel code will lock the channel to prevent
simultaneous calls to webchan_read, webchan_hangup, etc.

While we were here, the hangup code was refactored to use ast_hangup_with_cause
instead of directly queueing an AST_CONTROL_HANGUP frame.  This allows us
to set hangup causes and generate snapshots.

For a bit of extra debugging, a table of websocket close codes was added
to http_websocket.h with an accompanying "to string" function added to
res_http_websocket.c

Resolves: #1683
2026-01-15 16:47:31 +00:00
Sean Bright
791922ae5b asterisk.c: Allow multi-byte characters on the Asterisk CLI.
Versions of libedit that support Unicode expect that the
EL_GETCFN (the function that does character I/O) will fill in a
`wchar_t` with a character, which may be multi-byte. The built-in
function that libedit provides, but does not expose with a public API,
does properly handle multi-byte sequences.

Due to the design of Asterisk's console processing loop, Asterisk
provides its own implementation which does not handle multi-byte
characters. Changing Asterisk to use libedit's built-in function would
be ideal, but would also require changing some fundamental things
about console processing which could be fairly disruptive.

Instead, we bring in libedit's `read_char` implementation and modify
it to suit our specific needs.

Resolves: #60
2026-01-15 16:47:31 +00:00
Sean Bright
7f6b721516 func_presencestate.c: Allow NOT_SET to be set from CLI.
Resolves: #1647
2026-01-15 16:47:31 +00:00
Peter Krall
3a68e78696 res/ari/resource_bridges.c: Normalize channel_format ref handling for bridge media
Always take an explicit reference on the format used for bridge playback
and recording channels, regardless of where it was sourced, and release
it after prepare_bridge_media_channel. This aligns the code paths and
avoids mixing borrowed and owned references while preserving behavior.

Fixes: #1648
2026-01-15 16:47:31 +00:00
George Joseph
e6d4e62a78 res_geolocation: Fix multiple issues with XML generation.
* 3d positions were being rendered without an enclosing `<gml:pos>`
  element resulting in invalid XML.
* There was no way to set the `id` attribute on the enclosing `tuple`, `device`
  and `person` elements.
* There was no way to set the value of the `deviceID` element.
* Parsing of degree and radian UOMs was broken resulting in them appearing
  outside an XML element.
* The UOM schemas for degrees and radians were reversed.
* The Ellipsoid shape was missing and the Ellipse shape was defined multiple
  times.
* The `crs` location_info parameter, although documented, didn't work.
* The `pos3d` location_info parameter appears in some documentation but
  wasn't being parsed correctly.
* The retransmission-allowed and retention-expiry sub-elements of usage-rules
  were using the `gp` namespace instead of the `gbp` namespace.

In addition to fixing the above, several other code refactorings were
performed and the unit test enhanced to include a round trip
XML -> eprofile -> XML validation.

Resolves: #1667

UserNote: Geolocation: Two new optional profile parameters have been added.
* `pidf_element_id` which sets the value of the `id` attribute on the top-level
  PIDF-LO `device`, `person` or `tuple` elements.
* `device_id` which sets the content of the `<deviceID>` element.
Both parameters can include channel variables.

UpgradeNote: Geolocation: In order to correct bugs in both code and
documentation, the following changes to the parameters for GML geolocation
locations are now in effect:
* The documented but unimplemented `crs` (coordinate reference system) element
  has been added to the location_info parameter that indicates whether the `2d`
  or `3d` reference system is to be used. If the crs isn't valid for the shape
  specified, an error will be generated. The default depends on the shape
  specified.
* The Circle, Ellipse and ArcBand shapes MUST use a `2d` crs.  If crs isn't
  specified, it will default to `2d` for these shapes.
  The Sphere, Ellipsoid and Prism shapes MUST use a `3d` crs. If crs isn't
  specified, it will default to `3d` for these shapes.
  The Point and Polygon shapes may use either crs.  The default crs is `2d`
  however so if `3d` positions are used, the crs must be explicitly set to `3d`.
* The `geoloc show gml_shape_defs` CLI command has been updated to show which
  coordinate reference systems are valid for each shape.
* The `pos3d` element has been removed in favor of allowing the `pos` element
  to include altitude if the crs is `3d`.  The number of values in the `pos`
  element MUST be 2 if the crs is `2d` and 3 if the crs is `3d`.  An error
  will be generated for any other combination.
* The angle unit-of-measure for shapes that use angles should now be included
  in the respective parameter.  The default is `degrees`. There were some
  inconsistent references to `orientation_uom` in some documentation but that
  parameter never worked and is now removed.  See examples below.
Examples...
```
  location_info = shape="Sphere", pos="39.0 -105.0 1620", radius="20"
  location_info = shape="Point", crs="3d", pos="39.0 -105.0 1620"
  location_info = shape="Point", pos="39.0 -105.0"
  location_info = shape=Ellipsoid, pos="39.0 -105.0 1620", semiMajorAxis="20"
                semiMinorAxis="10", verticalAxis="0", orientation="25 degrees"
  pidf_element_id = ${CHANNEL(name)}-${EXTEN}
  device_id = mac:001122334455
  Set(GEOLOC_PROFILE(pidf_element_id)=${CHANNEL(name)}/${EXTEN})
```
2026-01-15 16:47:31 +00:00
George Joseph
7285079c6a stasis/control.c: Add destructor to timeout_datastore.
The timeout_datastore was missing a destructor resulting in a leak
of 16 bytes for every outgoing ARI call.

Resolves: #1681
2026-01-15 16:47:31 +00:00
Sean Bright
6c69acd917 func_talkdetect.c: Remove reference to non-existent variables. 2026-01-15 16:47:31 +00:00
Nathaniel Wesley Filardo
675490ad7b configure.ac: use AC_PATH_TOOL for nm
`nm` might, especially in cross-compilation scenarios, be available but prefixed with the target triple. So: use `AC_PATH_TOOL` rather than `AC_PATH_PROG` to find it. (See https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/Generic-Programs.html .)

Found and proposed fix tested by cross-compiling Asterisk using Nixpkgs on x86_64 targeting aarch64. :)
2026-01-15 16:47:31 +00:00
Alexei Gradinari
257fd8c180 res_pjsip_mwi: Fix off-nominal endpoint ao2 ref leak in mwi_get_notify_data
Delay acquisition of the ast_sip_endpoint reference in mwi_get_notify_data()
to avoid an ao2 ref leak on early-return error paths.

Move ast_sip_subscription_get_endpoint() to just before first use so all
acquired references are properly cleaned up.

Fixes: #1675
2026-01-15 16:47:31 +00:00
Maximilian Fridrich
c3b1313acf res_pjsip_messaging: Add support for following 3xx redirects
This commit integrates the redirect module into res_pjsip_messaging
to enable following 3xx redirect responses for outgoing SIP MESSAGEs.

When follow_redirect_methods contains 'message' on an endpoint, Asterisk
will now follow 3xx redirect responses for MESSAGEs, similar to how
it behaves for INVITE responses.

Resolves: #1576

UserNote: A new pjsip endpoint option follow_redirect_methods was added.
This option is a comma-delimited, case-insensitive list of SIP methods
for which SIP 3XX redirect responses are followed. An alembic upgrade
script has been added for adding this new option to the Asterisk
database.
2026-01-15 16:47:31 +00:00
Maximilian Fridrich
a105421d59 res_pjsip: Introduce redirect module for handling 3xx responses
This commit introduces a new redirect handling module that provides
infrastructure for following SIP 3xx redirect responses. The redirect
functionality respects the endpoint's redirect_method setting and only
follows redirects when set to 'uri_pjsip'. This infrastructure can be
used by any PJSIP module that needs to handle 3xx redirect responses.
2026-01-15 16:47:31 +00:00
Tinet-mucw
1a99775f65 app_mixmonitor.c: Fix crash in mixmonitor_ds_remove_and_free when datastore is NULL
The datastore may be NULL, so a null pointer check needs to be added.

Resolves: #1673
2026-01-15 16:47:31 +00:00
Sven Kube
593f09dc6e res_pjsip_refer: don't defer session termination for ari transfer
Allow session termination during an in progress ari handled transfer.
2026-01-15 16:47:31 +00:00
Naveen Albert
98d4f55d07 chan_dahdi.conf.sample: Avoid warnings with default configs.
callgroup and pickupgroup may only be specified for FXO-signaled channels;
however, the chan_dahdi sample config had these options uncommented in
the [channels] section, thus applying these settings to all channels,
resulting in warnings. Comment these out so there are no warnings with
an unmodified sample config.

Resolves: #1552
2026-01-15 16:47:31 +00:00
sarangr7
7530908a1d main/dial.c: Set channel hangup cause on timeout in handle_timeout_trip
When dial attempts timeout in the core dialing API, the channel's hangup
cause was not being set before hanging up. Only the ast_dial_channel
structure's internal cause field was updated, but the actual ast_channel
hangup cause remained unset.

This resulted in incorrect or missing hangup cause information being
reported through CDRs, AMI events, and other mechanisms that read the
channel's hangup cause when dial timeouts occurred via applications
using the dialing API (FollowMe, Page, etc.).

The fix adds proper channel locking and sets AST_CAUSE_NO_ANSWER on
the channel before calling ast_hangup(), ensuring consistent hangup
cause reporting across all interfaces.

Resolves: #1660
2026-01-15 16:47:31 +00:00
Sean Bright
890c2835e2 cel: Add missing manager documentation.
The LOCAL_OPTIMIZE_BEGIN, STREAM_BEGIN, STREAM_END, and DTMF CEL
events were not all documented in the CEL configuration file or the
manager documentation for the CEL event.
2026-01-15 16:47:31 +00:00
Sean Bright
5e70744dba res_odbc: Use SQL_SUCCEEDED() macro where applicable.
This is just a cleanup of some repetitive code.
2026-01-15 16:47:31 +00:00
Justin T. Gibbs
2fdf1c5942 rtp/rtcp: Configure dual-stack behavior via IPV6_V6ONLY
Dual-stack behavior (simultaneous listening for IPV4 and IPV6
connections on a single socket) is required by Asterisk's ICE
implementation.  On systems with the IPV6_V6ONLY sockopt, set
the option to 0 (dual-stack enabled) when binding to the IPV6
any address. This ensures correct behavior regardless of the
system's default dual-stack configuration.
2026-01-15 16:47:31 +00:00
Sean Bright
1217dac239 http.c: Include remote address in URI handler message.
Resolves: #1662
2026-01-15 16:47:31 +00:00
Joshua C. Colp
e819303210 pjsip: Move from threadpool to taskpool
This change moves the PJSIP module from the threadpool API
to the taskpool API. PJSIP-specific implementations for
task usage have been removed and replaced with calls to
the optimized taskpool implementations instead. The need
for a pool of serializers has also been removed as
taskpool inherently provides this. The default settings
have also been changed to be more realistic for common
usage.

UpgradeNote: The threadpool_* options in pjsip.conf have now
been deprecated though they continue to be read and used.
They have been replaced with taskpool options that give greater
control over the underlying taskpool used for PJSIP. An alembic
upgrade script has been added to add these options to realtime
as well.
2026-01-15 16:47:31 +00:00
phoneben
baf45ca711 Disable device state caching for ephemeral channels
chan_audiosocket/chan_rtp/res_stasis_snoop: Disable device state caching for ephemeral channels

Resolves: #1638
2026-01-15 16:47:31 +00:00
George Joseph
1514409cd3 chan_websocket: Add locking in send_event and check for NULL websocket handle.
On an outbound websocket connection, when the triggering caller hangs up,
webchan_hangup() closes the outbound websocket session and sets the websocket
session handle to NULL.  If the hangup happened in the tiny window between
opening the outbound websocket connection and before read_thread_handler()
was able to send the MEDIA_START message, it could segfault because the
websocket session handle was NULL.  If it didn't actually segfault, there was
also the possibility that the websocket instance wouldn't get cleaned up which
could also cause the channel snapshot to not get cleaned up.  That could
cause memory leaks and `core show channels` to list phantom WebSocket
channels.

To prevent the race, the send_event() macro now locks the websocket_pvt
instance and checks the websocket session handle before attempting to send
the MEDIA_START message.

Resolves: #1643
Resolves: #1645
2026-01-15 16:47:31 +00:00
phoneben
eef58222eb Fix false null-deref warning in channel_state
Resolve analyzer warning in channel_state by checking AST_FLAG_DEAD on snapshot, which is guaranteed non-NULL.

Resolves: #1430
2026-01-15 16:47:30 +00:00
George Joseph
fe34638884 endpoint.c: Plug a memory leak in ast_endpoint_shutdown().
Commit 26795be introduced a memory leak of ast_endpoint when
ast_endpoint_shutdown() was called. The leak occurs only if a configuration
change removes an endpoint and isn't related to call volume or the length of
time asterisk has been running.  An ao2_ref(-1) has been added to
ast_endpoint_shutdown() to plug the leak.

Resolves: #1635
2026-01-15 16:47:30 +00:00
Sean Bright
7f8de63b54 Revert "func_hangupcause.c: Add access to Reason headers via HANGUPCAUSE()"
This reverts commit 5177662990.

For rationale, see #1621 and #1606
2026-01-15 16:47:30 +00:00
Sean Bright
94e592965c cel_manager.c: Correct manager event mask for CEL events.
There is no EVENT_FLAG_CEL and these events are raised with as
EVENT_FLAG_CALL.
2026-01-15 16:47:30 +00:00
Sean Bright
041b1542ce app_queue.c: Update docs to correct QueueMemberPause event name. 2026-01-15 16:47:30 +00:00
Mike Bradeen
ee3b139739 taskprocessors: Improve logging and add new cli options
This change makes some small changes to improve log readability in
addition to the following changes:

Modified 'core show taskprocessors' to now show Low time and High time
for task execution.

New command 'core show taskprocessor name <taskprocessor-name>' to dump
taskprocessor info and current queue.

Addionally, a new test was added to demonstrate the 'show taskprocessor
name' functionality:
test execute category /main/taskprocessor/ name taskprocessor_cli_show

Setting 'core set debug 3 taskprocessor.c' will now log pushed tasks.
(Warning this is will cause extremely high levels of logging at even
low traffic levels.)

Resolves: #1566

UserNote: New CLI command has been added -
core show taskprocessor name <taskprocessor-name>
2026-01-15 16:47:30 +00:00