Commit Graph

34061 Commits

Author SHA1 Message Date
James Terhune
a8f873fb35 main/stasis_channels.c: Fix crash when setting a global variable with invalid UTF8 characters
Add check for null value of chan before referencing it with ast_channel_name()

Resolves: #999
(cherry picked from commit bece08dcf8)
2025-01-23 18:39:41 +00:00
George Joseph
c5734b4ae6 res_stir_shaken: Allow sending Identity headers for unknown TNs
Added a new option "unknown_tn_attest_level" to allow Identity
headers to be sent when a callerid TN isn't explicitly configured
in stir_shaken.conf.  Since there's no TN object, a private_key_file
and public_cert_url must be configured in the attestation or profile
objects.

Since "unknown_tn_attest_level" uses the same enum as attest_level,
some of the sorcery macros had to be refactored to allow sharing
the enum and to/from string conversion functions.

Also fixed a memory leak in crypto_utils:pem_file_cb().

Resolves: #921

UserNote: You can now set the "unknown_tn_attest_level" option
in the attestation and/or profile objects in stir_shaken.conf to
enable sending Identity headers for callerid TNs not explicitly
configured.

(cherry picked from commit 90cf13acd8)
2025-01-23 18:39:41 +00:00
Asterisk Development Team
712ec3f801 Update for 21.6.1 21.6.1 2025-01-09 19:35:04 +00:00
Ben Ford
fb2b0b240b manager.c: Restrict ListCategories to the configuration directory.
When using the ListCategories AMI action, it was possible to traverse
upwards through the directories to files outside of the configured
configuration directory. This action is now restricted to the configured
directory and an error will now be returned if the specified file is
outside of this limitation.

Resolves: #GHSA-33x6-fj46-6rfh

UserNote: The ListCategories AMI action now restricts files to the
configured configuration directory.
2025-01-09 13:13:47 -06:00
Asterisk Development Team
68987d4e8a Update for 21.6.0 21.6.0 2024-11-21 17:17:48 +00:00
George Joseph
43b4863b8a res_pjsip: Change suppress_moh_on_sendonly to OPT_BOOL_T
The suppress_moh_on_sendonly endpoint option should have been
defined as OPT_BOOL_T in pjsip_configuration.c and AST_BOOL_VALUES
in the alembic script instead of OPT_YESNO_T and YESNO_VALUES.

Also updated contrib/ast-db-manage/README.md to indicate that
AST_BOOL_VALUES should always be used and provided an example.

Resolves: #995
2024-11-19 12:55:40 -07:00
Asterisk Development Team
4894194917 Update for 21.6.0-rc1 21.6.0-rc1 2024-11-14 20:01:38 +00:00
George Joseph
34ba2038e9 res_pjsip: Add new endpoint option "suppress_moh_on_sendonly"
Normally, when one party in a call sends Asterisk an SDP with
a "sendonly" or "inactive" attribute it means "hold" and causes
Asterisk to start playing MOH back to the other party. This can be
problematic if it happens at certain times, such as in a 183
Progress message, because the MOH will replace any early media you
may be playing to the calling party. If you set this option
to "yes" on an endpoint and the endpoint receives an SDP
with "sendonly" or "inactive", Asterisk will NOT play MOH back to
the other party.

Resolves: #979

UserNote: The new "suppress_moh_on_sendonly" endpoint option
can be used to prevent playing MOH back to a caller if the remote
end sends "sendonly" or "inactive" (hold) to Asterisk in an SDP.

(cherry picked from commit badf203203)
2024-11-14 20:01:35 +00:00
Sean Bright
647016e5e2 res_pjsip.c: Fix Contact header rendering for IPv6 addresses.
Fix suggested by @nvsystems.

Fixes #985

(cherry picked from commit 5c76486203)
2024-11-14 20:01:35 +00:00
chrsmj
58a3b6f69a samples: remove and/or change some wiki mentions
Cleaned some dead links. Replaced word wiki with
either docs or link to https://docs.asterisk.org/

Resolves: #974
(cherry picked from commit eabd7a26ea)
2024-11-14 20:01:35 +00:00
George Joseph
31c87d1b85 func_pjsip_aor/contact: Fix documentation for contact ID
Clarified the use of the contact ID returned from PJSIP_AOR.

Resolves: #990
(cherry picked from commit a04e4f38fe)
2024-11-14 20:01:35 +00:00
George Joseph
f2fe378b06 res_pjsip: Move tenantid to end of ast_sip_endpoint
The tenantid field was originally added to the ast_sip_endpoint
structure at the end of the AST_DECLARE_STRING_FIELDS block.  This
caused everything after it in the structure to move down in memory
and break ABI compatibility.  It's now at the end of the structure
as an AST_STRING_FIELD_EXTENDED.  Given the number of string fields
in the structure now, the initial string field allocation was
also increased from 64 to 128 bytes.

Resolves: #982
(cherry picked from commit be8f3a3fa4)
2024-11-14 20:01:35 +00:00
Thomas Guebels
56e48b05b5 pjsip_transport_events: handle multiple addresses for a domain
The key used for transport monitors was the remote host name for the
transport and not the remote address resolved for this domain.

This was problematic for domains returning multiple addresses as several
transport monitors were created with the same key.

Whenever a subsystem wanted to register a callback it would always end
up attached to the first transport monitor with a matching key.

The key used for transport monitors is now the remote address and port
the transport actually connected to.

Fixes: #932
(cherry picked from commit 2ee258b0fc)
2024-11-14 20:01:35 +00:00
Naveen Albert
2b9409debf func_evalexten: Add EVAL_SUB function.
This adds an EVAL_SUB function, which is similar to the existing
EVAL_EXTEN function but significantly more powerful, as it allows
executing arbitrary dialplan and capturing its return value as
the function's output. While EVAL_EXTEN should be preferred if it
is possible to use it, EVAL_SUB can be used in a wider variety
of cases and allows arbitrary computation to be performed in
a dialplan function call, leveraging the dialplan.

Resolves: #951
(cherry picked from commit b01a3cfdcb)
2024-11-14 20:01:35 +00:00
George Joseph
0a69e8397d res_srtp: Change Unsupported crypto suite msg from verbose to debug
There's really no point in spamming logs with a verbose message
for every unsupported crypto suite an older client may send
in an SDP.  If none are supported, there will be an error or
warning.

(cherry picked from commit 50bd50d798)
2024-11-14 20:01:34 +00:00
Ben Ford
d2a2e8c912 Add res_pjsip_config_sangoma external module.
Adds res_pjsip_config_sangoma as an external module that can be
downloaded via menuselect. It lives under the Resource Modules section.

(cherry picked from commit b8d818bd3c)
2024-11-14 20:01:34 +00:00
Ben Ford
c895d3692e app_mixmonitor: Add 'D' option for dual-channel audio.
Adds the 'D' option to app_mixmonitor that interleaves the input and
output frames of the channel being recorded in the monitor output frame.
This allows for two streams in the recording: the transmitted audio and
the received audio. The 't' and 'r' options are compatible with this.

Fixes: #945

UserNote: The MixMonitor application now has a new 'D' option which
interleaves the recorded audio in the output frames. This allows for
stereo recording output with one channel being the transmitted audio and
the other being the received audio. The 't' and 't' options are
compatible with this.

(cherry picked from commit 8273eefd87)
2024-11-14 20:01:34 +00:00
Thomas Guebels
9374ae1036 pjsip_transport_events: Avoid monitor destruction
When a transport is disconnected, several events can arrive following
each other. The first event will be PJSIP_TP_STATE_DISCONNECT and it
will trigger the destruction of the transport monitor object. The lookup
for the transport monitor to destroy is done using the transport key,
that contains the transport destination host:port.

A reconnect attempt by pjsip will be triggered as soon something needs to
send a packet using that transport. This can happen directly after a
disconnect since ca

Subsequent events can arrive later like PJSIP_TP_STATE_DESTROY and will
also try to trigger the destruction of the transport monitor if not
already done. Since the lookup for the transport monitor to destroy is
done using the transport key, it can match newly created transports
towards the same destination and destroy their monitor object.

Because of this, it was sometimes not possible to monitor a transport
after one or more disconnections.

This fix adds an additional check on the transport pointer to ensure
only a monitor for that specific transport is removed.

Fixes: #923
(cherry picked from commit 6763dda90f)
2024-11-14 20:01:34 +00:00
George Joseph
fc8c518709 .github: Redirect NightlyAdmin to AsteriskNightlyAdmin
(cherry picked from commit 3b2bde6c48)
2024-11-14 20:01:34 +00:00
George Joseph
4ea6f819ee .github: NightlyAdmin now calls external CloseStaleIssuesAndPRs
(cherry picked from commit ce322ad16a)
2024-11-14 20:01:34 +00:00
Naveen Albert
1b31ced994 app_dial: Fix progress timeout calculation with no answer timeout.
If to_answer is -1, simply comparing to see if the progress timeout
is smaller than the answer timeout to prefer it will fail. Add
an additional check that chooses the progress timeout if there is
no answer timeout (or as before, if the progress timeout is smaller).

Resolves: #821
(cherry picked from commit 6a07e8e0f1)
2024-11-14 20:01:34 +00:00
George Joseph
bfe56d18c4 pjproject_bundled: Tweaks to support out-of-tree development
* pjproject is now configured with --disable-libsrtp so it will
  build correctly when doing "out-of-tree" development.  Asterisk
  doesn't use pjproject for handling media so pjproject doesn't
  need libsrtp itself.

* The pjsua app (which we used to use for the testsuite) no longer
  builds in pjproject's master branch so we just skip it.  The
  testsuite no longer needs it anyway.

See third-party/pjproject/README-hacking.md for more info on building
pjproject "out-of-tree".

(cherry picked from commit 23218032ef)
2024-11-14 20:01:34 +00:00
Sean Bright
16d8c3f438 Revert "res_rtp_asterisk: Count a roll-over of the sequence number even on lost packets."
This reverts commit cb5e3445be.

The original change from 16 to 15 bit sequence numbers was predicated
on the following from the now-defunct libSRTP FAQ on sourceforge.net:

> *Q6. The use of implicit synchronization via ROC seems
> dangerous. Can senders and receivers lose ROC synchronization?*
>
> **A.** It is possible to lose ROC synchronization between sender and
> receiver(s), though it is not likely in practice, and practical
> steps can be taken to avoid it. A burst loss of 2^16 packets or more
> will always break synchronization. For example, a conversational
> voice codec that sends 50 packets per second will have its ROC
> increment about every 22 minutes. A network with a burst of packet
> loss that long has problems other than ROC synchronization.
>
> There is a higher sensitivity to loss at the very outset of an SRTP
> stream. If the sender's initial sequence number is close to the
> maximum value of 2^16-1, and all packets are lost from the initial
> packet until the sequence number cycles back to zero, the sender
> will increment its ROC, but the receiver will not. The receiver
> cannot determine that the initial packets were lost and that
> sequence-number rollover has occurred. In this case, the receiver's
> ROC would be zero whereas the sender's ROC would be one, while their
> sequence numbers would be so close that the ROC-guessing algorithm
> could not detect this fact.
>
> There is a simple solution to this problem: the SRTP sender should
> randomly select an initial sequence number that is always less than
> 2^15. This ensures correct SRTP operation so long as fewer than 2^15
> initial packets are lost in succession, which is within the maximum
> tolerance of SRTP packet-index determination (see Appendix A and
> page 14, first paragraph of RFC 3711). An SRTP receiver should
> carefully implement the index-guessing algorithm. A naive
> implementation can unintentionally guess the value of
> 0xffffffffffffLL whenever the SEQ in the packet is greater than 2^15
> and the locally stored SEQ and ROC are zero. (This can happen when
> the implementation fails to treat those zero values as a special
> case.)
>
> When ROC synchronization is lost, the receiver will not be able to
> properly process the packets. If anti-replay protection is turned
> on, then the desynchronization will appear as a burst of replay
> check failures. Otherwise, if authentication is being checked, then
> it will appear as a burst of authentication failures. Otherwise, if
> encryption is being used, the desynchronization may not be detected
> by the SRTP layer, and the packets may be improperly decrypted.

However, modern libSRTP (as of 1.0.1[1]) now mentions the following in
their README.md[2]:

> The sequence number in the rtp packet is used as the low 16 bits of
> the sender's local packet index. Note that RTP will start its
> sequence number in a random place, and the SRTP layer just jumps
> forward to that number at its first invocation. An earlier version
> of this library used initial sequence numbers that are less than
> 32,768; this trick is no longer required as the
> rdbx_estimate_index(...) function has been made smarter.

So truncating our initial sequence number to 15 bit is no longer
necessary.

1. 0eb007f0dc/CHANGES (L271-L289)
2. 2de20dd9e9/README.md (implementation-notes)

(cherry picked from commit f3138af519)
2024-11-14 20:01:34 +00:00
George Joseph
5989b1ea02 core_unreal.c: Fix memory leak in ast_unreal_new_channels()
When the channel tech is multistream capable, the reference to
chan_topology was passed to the new channel.  When the channel tech
isn't multistream capable, the reference to chan_topology was never
released.  "Local" channels are multistream capable so it didn't
affect them but the confbridge "CBAnn" and the bridge_media
"Recorder" channels are not so they caused a leak every time one
of them was created.

Also added tracing to ast_stream_topology_alloc() and
stream_topology_destroy() to assist with debugging.

Resolves: #938
(cherry picked from commit e434203810)
2024-11-14 20:01:34 +00:00
Allan Nathanson
b104c5837d dnsmgr.c: dnsmgr_refresh() incorrectly flags change with DNS round-robin
The dnsmgr_refresh() function checks to see if the IP address associated
with a name/service has changed. The gotcha is that the ast_get_ip_or_srv()
function only returns the first IP address returned by the DNS query. If
there are multiple IPs associated with the name and the returned order is
not consistent (e.g. with DNS round-robin) then the other IP addresses are
not included in the comparison and the entry is flagged as changed even
though the IP is still valid.

Updated the code to check all IP addresses and flag a change only if the
original IP is no longer valid.

Resolves: #924
(cherry picked from commit 4a3319a587)
2024-11-14 20:01:34 +00:00
George Joseph
3274a639b1 geolocation.sample.conf: Fix comment marker at end of file
Resolves: #937
(cherry picked from commit 00d72b0e9e)
2024-11-14 20:01:34 +00:00
Sean Bright
b3a0437dec func_base64.c: Ensure we set aside enough room for base64 encoded data.
Reported by SingularTricycle on IRC.

Fixes #940

(cherry picked from commit 7c359a2dd3)
2024-11-14 20:01:34 +00:00
Naveen Albert
c8d1c29a52 app_dial: Fix progress timeout.
Under some circumstances, the progress timeout feature added in commit
320c98eec8 does not work as expected,
such as if there is no media flowing. Adjust the waitfor call to
explicitly use the progress timeout if it would be reached sooner than
the answer timeout to ensure we handle the timers properly.

Resolves: #821
(cherry picked from commit 97dfe4cd40)
2024-11-14 20:01:34 +00:00
Naveen Albert
7d8bb3302e chan_dahdi: Never send MWI while off-hook.
In some circumstances, it is possible for the do_monitor thread to
erroneously think that a line is on-hook and send an MWI FSK spill
to it when the line is really off-hook and no MWI should be sent.
Commit 0a8b3d3467 previously fixed this
issue in a more readily encountered scenario, but it has still been
possible for MWI to be sent when it shouldn't be. To robustly fix
this issue, query DAHDI for the hook status to ensure we don't send
MWI on a line that is actually still off hook.

Resolves: #928
(cherry picked from commit 63e9cc19d1)
2024-11-14 20:01:34 +00:00
George Joseph
0f55b9172c manager.c: Add unit test for Originate app and appdata permissions
This unit test checks that dialplan apps and app data specified
as parameters for the Originate action are allowed with the
permissions the user has.

(cherry picked from commit 5cf699370b)
2024-11-14 20:01:34 +00:00
Sean Bright
6d86566ee8 alembic: Drop redundant voicemail_messages index.
The `voicemail_messages_dir` index is a left prefix of the table's
primary key and therefore unnecessary.

(cherry picked from commit f97ad807ff)
2024-11-14 20:01:34 +00:00
Sean Bright
5152a05416 res_agi.c: Ensure SIGCHLD handler functions are properly balanced.
Calls to `ast_replace_sigchld()` and `ast_unreplace_sigchld()` must be
balanced to ensure that we can capture the exit status of child
processes when we need to. This extends to functions that call
`ast_replace_sigchld()` and `ast_unreplace_sigchld()` such as
`ast_safe_fork()` and `ast_safe_fork_cleanup()`.

The primary change here is ensuring that we do not call
`ast_safe_fork_cleanup()` in `res_agi.c` if we have not previously
called `ast_safe_fork()`.

Additionally we reinforce some of the documentation and add an
assertion to, ideally, catch this sooner were this to happen again.

Fixes #922

(cherry picked from commit 243f20a78d)
2024-11-14 20:01:34 +00:00
Naveen Albert
107c9e7c68 main, res, tests: Fix compilation errors on FreeBSD.
asterisk.c, manager.c: Increase buffer sizes to avoid truncation warnings.
config.c: Include header file for WIFEXITED/WEXITSTATUS macros.
res_timing_kqueue: Use more portable format specifier.
test_crypto: Use non-linux limits.h header file.

Resolves: #916
(cherry picked from commit b8b21b3f00)
2024-11-14 20:01:34 +00:00
George Joseph
2f3b10d1b2 res_rtp_asterisk: Fix dtls timer issues causing FRACKs and SEGVs
In dtls_srtp_handle_timeout(), when DTLSv1_get_timeout() returned
success but with a timeout of 0, we were stopping the timer and
decrementing the refcount on instance but not resetting the
timeout_timer to -1.  When dtls_srtp_stop_timeout_timer()
was later called, it was atempting to stop a stale timer and could
decrement the refcount on instance again which would then cause
the instance destructor to run early.  This would result in either
a FRACK or a SEGV when ast_rtp_stop(0 was called.

According to the OpenSSL docs, we shouldn't have been stopping the
timer when DTLSv1_get_timeout() returned success and the new timeout
was 0 anyway.  We should have been calling DTLSv1_handle_timeout()
again immediately so we now reschedule the timer callback for
1ms (almost immediately).

Additionally, instead of scheduling the timer callback at a fixed
interval returned by the initial call to DTLSv1_get_timeout()
(usually 999 ms), we now reschedule the next callback based on
the last call to DTLSv1_get_timeout().

Resolves: #487
(cherry picked from commit 7db8ae296c)
2024-11-14 20:01:34 +00:00
Ben Ford
8fe0e55d96 manager.c: Restrict ModuleLoad to the configured modules directory.
When using the ModuleLoad AMI action, it was possible to traverse
upwards through the directories to files outside of the configured
modules directory. We decided it would be best to restrict access to
modules exclusively in the configured directory. You will now get an
error when the specified module is outside of this limitation.

Fixes: #897

UserNote: The ModuleLoad AMI action now restricts modules to the
configured modules directory.

(cherry picked from commit e8d3869e75)
2024-11-14 20:01:34 +00:00
jiangxc
f7b9575241 res_agi.c: Prevent possible double free during SPEECH RECOGNIZE
When using the speech recognition module, crashes can occur
sporadically due to a "double free or corruption (out)" error. Now, in
the section where the audio stream is being captured in a loop, each
time after releasing fr, it is set to NULL to prevent repeated
deallocation.

Fixes #772

(cherry picked from commit 2d676c7560)
2024-11-14 20:01:34 +00:00
Sean Bright
c1df33a717 cdr_custom: Allow absolute filenames.
A follow up to #893 that brings the same functionality to
cdr_custom. Also update the sample configuration files to note support
for absolute paths.

(cherry picked from commit 084c04f711)
2024-11-14 20:01:34 +00:00
Naveen Albert
10963cd27e astfd.c: Avoid calling fclose with NULL argument.
Don't pass through a NULL argument to fclose, which is undefined
behavior, and instead return -1 and set errno appropriately. This
also avoids a compiler warning with glibc 2.38 and newer, as glibc
commit 71d9e0fe766a3c22a730995b9d024960970670af
added the nonnull attribute to this argument.

Resolves: #900
(cherry picked from commit 7c982de5c6)
2024-11-14 20:01:34 +00:00
Peter Jannesen
7147440560 channel: Preserve CHANNEL(userfield) on masquerade.
In certain circumstances a channel may undergo an operation
referred to as a masquerade. If this occurs the CHANNEL(userfield)
value was not preserved causing it to get lost. This change makes
it so that this field is now preserved.

Fixes: #882
(cherry picked from commit f3e74d34ce)
2024-11-14 20:01:34 +00:00
Peter Jannesen
db9ca72e15 cel_custom: Allow absolute filenames.
If a filename starts with a '/' in cel_custom [mappings] assume it is
a absolute file path and not relative filename/path to
AST_LOG_DIR/cel_custom/

(cherry picked from commit 0ed7f5800d)
2024-11-14 20:01:34 +00:00
Naveen Albert
6da65e52d3 app_voicemail: Fix ill-formatted pager emails with custom subject.
Add missing end-of-headers newline to pager emails with custom
subjects, since this was missing from this code path.

Resolves: #902
(cherry picked from commit 9423710a5e)
2024-11-14 20:01:34 +00:00
Sean Bright
ea0edbf456 res_pjsip_pubsub: Persist subscription 'generator_data' in sorcery
Fixes #895

(cherry picked from commit 3243316dac)
2024-11-14 20:01:34 +00:00
George Joseph
eda57823be Fix application references to Background
The app is actually named "BackGround" but several references
in XML documentation were spelled "Background" with the lower
case "g".  This was causing documentation links to return
"not found" messages.

(cherry picked from commit 48acf00eab)
2024-11-14 20:01:34 +00:00
George Joseph
16dabda021 manager.conf.sample: Fix mathcing typo
(cherry picked from commit ce35f5684b)
2024-11-14 20:01:34 +00:00
George Joseph
c2f0f17580 manager: Enhance event filtering for performance
UserNote: You can now perform more granular filtering on events
in manager.conf using expressions like
`eventfilter(name(Newchannel),header(Channel),method(starts_with)) = PJSIP/`
This is much more efficient than
`eventfilter = Event: Newchannel.*Channel: PJSIP/`
Full syntax guide is in configs/samples/manager.conf.sample.

(cherry picked from commit 92c0bd4b50)
2024-11-14 20:01:34 +00:00
George Joseph
ec728d96b3 manager.c: Split XML documentation to manager_doc.xml
(cherry picked from commit a26e79dfe2)
2024-11-14 20:01:34 +00:00
George Joseph
c4ba44db52 .github: Fix realtime param on Weekly and Nightly tests and...
Rename the "Cleanup" job in the cherry-pick and recheck jobs
to "Summary".

(cherry picked from commit 94237f684a)
2024-11-14 20:01:34 +00:00
George Joseph
96e6144d55 .github: Add WeeklyTests and make Nightlies Monday-Saturday
...and add "realtime" option.

(cherry picked from commit 60ad3efc9d)
2024-11-14 20:01:34 +00:00
George Joseph
e65b3f0faa db.c: Remove limit on family/key length
Consumers like media_cache have been running into issues with
the previous astdb "/family/key" limit of 253 bytes when needing
to store things like long URIs.  An Amazon S3 URI is a good example
of this.  Now, instead of using a static 256 byte buffer for
"/family/key", we use ast_asprintf() to dynamically create it.

Both test_db.c and test_media_cache.c were also updated to use
keys/URIs over the old 253 character limit.

Resolves: #881

UserNote: The `ast_db_*()` APIs have had the 253 byte limit on
"/family/key" removed and will now accept families and keys with a
total length of up to SQLITE_MAX_LENGTH (currently 1e9!).  This
affects the `DB*` dialplan applications, dialplan functions,
manager actions and `databse` CLI commands.  Since the
media_cache also uses the `ast_db_*()` APIs, you can now store
resources with URIs longer than 253 bytes.

(cherry picked from commit cc06c95ed2)
2024-11-14 20:01:34 +00:00
George Joseph
93a774447f .github: Changes required to use cached builds and shorten names
(cherry picked from commit 24d641f40a)
2024-11-14 20:01:34 +00:00