Commit Graph

33983 Commits

Author SHA1 Message Date
Asterisk Development Team
0376da363c Update for 18.26.2 18.26.2 2025-05-22 15:50:16 +00:00
George Joseph
ef1ad68131 asterisk.c: Add option to restrict shell access from remote consoles.
UserNote: A new asterisk.conf option 'disable_remote_console_shell' has
been added that, when set, will prevent remote consoles from executing
shell commands using the '!' prefix.

Resolves: #GHSA-c7p6-7mvq-8jq2
2025-05-22 09:00:01 -06:00
George Joseph
31fcbf1283 res_pjsip_messaging.c: Mask control characters in received From display name
Incoming SIP MESSAGEs will now have their From header's display name
sanitized by replacing any characters < 32 (space) with a space.

Resolves: #GHSA-2grh-7mhv-fcfw
2025-05-22 08:28:01 -06:00
Asterisk Development Team
99075c0dd5 Update for 18.26.1 18.26.1 2025-01-09 19:34:22 +00:00
Ben Ford
ffc2aeaa8f 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:09:13 -06:00
Asterisk Development Team
3f3dab0bfe Update for 18.26.0 18.26.0 2024-11-21 17:16:56 +00:00
Asterisk Development Team
be6dd21420 Update for 18.26.0-rc1 18.26.0-rc1 2024-11-14 20:00:49 +00:00
George Joseph
ca5b810fe3 .github: Redirect NightlyAdmin to AsteriskNightlyAdmin
(cherry picked from commit 38a18f9fbb)
2024-11-14 20:00:45 +00:00
George Joseph
ba30b87e91 .github: NightlyAdmin now calls external CloseStaleIssuesAndPRs
(cherry picked from commit 678646f7d3)
2024-11-14 20:00:45 +00:00
Naveen Albert
c70587e43e 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 485ccb7429)
2024-11-14 20:00:45 +00:00
George Joseph
79e072c9a1 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 f9e8c3488b)
2024-11-14 20:00:45 +00:00
Sean Bright
351d853dfd chan_sip.c: Fix __sip_reliable_xmit build error
Fixes #954

(cherry picked from commit 909b93608a)
2024-11-14 20:00:45 +00:00
Sean Bright
77bbf67e0b 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 e3a0ca20b5)
2024-11-14 20:00:45 +00:00
George Joseph
b09a49e8dd 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 d6ffbff333)
2024-11-14 20:00:45 +00:00
Allan Nathanson
fddb8270e8 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 99221c81ed)
2024-11-14 20:00:45 +00:00
George Joseph
798eb9f022 geolocation.sample.conf: Fix comment marker at end of file
Resolves: #937
(cherry picked from commit f9d5d659c6)
2024-11-14 20:00:45 +00:00
Sean Bright
3bd08e8924 func_base64.c: Ensure we set aside enough room for base64 encoded data.
Reported by SingularTricycle on IRC.

Fixes #940

(cherry picked from commit fae5d21b6a)
2024-11-14 20:00:45 +00:00
Naveen Albert
6c840886a9 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 62b6ea3202)
2024-11-14 20:00:45 +00:00
Naveen Albert
7057658110 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 fa614f755d)
2024-11-14 20:00:45 +00:00
George Joseph
bc67e339ae 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 29e0d77765)
2024-11-14 20:00:45 +00:00
Sean Bright
37df170bdc 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 776bb8c56b)
2024-11-14 20:00:45 +00:00
Sean Bright
7973b7474a 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 c80ce750bb)
2024-11-14 20:00:45 +00:00
Naveen Albert
423f0bdc99 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 f415e313b4)
2024-11-14 20:00:45 +00:00
George Joseph
c9bfbd9959 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 ec2e26cfe7)
2024-11-14 20:00:45 +00:00
Ben Ford
aaa594fb64 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 5a237235c0)
2024-11-14 20:00:45 +00:00
jiangxc
003be5aff0 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 e1da2fec42)
2024-11-14 20:00:45 +00:00
Sean Bright
aa1f38a17a 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 9da3bdefef)
2024-11-14 20:00:45 +00:00
Naveen Albert
6208e9c31c 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 b29776a5b0)
2024-11-14 20:00:45 +00:00
Peter Jannesen
d54206221f 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 e522eb6357)
2024-11-14 20:00:45 +00:00
Peter Jannesen
463e4f96c5 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 9e76533f90)
2024-11-14 20:00:45 +00:00
Naveen Albert
ec990d6a6e 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 44a6349b69)
2024-11-14 20:00:45 +00:00
Sean Bright
aa4542d67f res_pjsip_pubsub: Persist subscription 'generator_data' in sorcery
Fixes #895

(cherry picked from commit a6db5455ac)
2024-11-14 20:00:45 +00:00
George Joseph
3b73137f15 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 29d6a62768)
2024-11-14 20:00:45 +00:00
George Joseph
1c8fcc2417 manager.conf.sample: Fix mathcing typo
(cherry picked from commit 1805801588)
2024-11-14 20:00:45 +00:00
George Joseph
758f72e8ae 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 a9f16f23ae)
2024-11-14 20:00:45 +00:00
George Joseph
ab1a152664 manager.c: Split XML documentation to manager_doc.xml
(cherry picked from commit 539009cbed)
2024-11-14 20:00:45 +00:00
George Joseph
038ef99d17 .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 5c25f268c8)
2024-11-14 20:00:45 +00:00
George Joseph
b0431b05c3 .github: Add WeeklyTests and make Nightlies Monday-Saturday
...and add "realtime" option.

(cherry picked from commit 43c4d2537a)
2024-11-14 20:00:45 +00:00
George Joseph
2ddeea3842 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 01aa84e42f)
2024-11-14 20:00:45 +00:00
George Joseph
7977e17a2d .github: Changes required to use cached builds and shorten names
(cherry picked from commit c535a1d2cd)
2024-11-14 20:00:45 +00:00
Asterisk Development Team
8a20121298 Update for 18.25.0 18.25.0 2024-10-17 16:03:29 +00:00
Asterisk Development Team
30cbe03fd0 Update for 18.25.0-rc2 18.25.0-rc2 2024-09-26 16:17:15 +00:00
George Joseph
42697aa980 stir_shaken: Fix propagation of attest_level and a few other values
attest_level, send_mky and check_tn_cert_public_url weren't
propagating correctly from the attestation object to the profile
and tn.

* In the case of attest_level, the enum needed to be changed
so the "0" value (the default) was "NOT_SET" instead of "A".  This
now allows the merging of the attestation object, profile and tn
to detect when a value isn't set and use the higher level value.

* For send_mky and check_tn_cert_public_url, the tn default was
forced to "NO" which always overrode the profile and attestation
objects.  Their defaults are now "NOT_SET" so the propagation
happens correctly.

* Just to remove some redundant code in tn_config.c, a bunch of calls to
generate_sorcery_enum_from_str() and generate_sorcery_enum_to_str() were
replaced with a single call to generate_acfg_common_sorcery_handlers().

Resolves: #904
2024-09-26 10:39:01 -05:00
George Joseph
a64357c9ac res_stir_shaken: Remove stale include for jansson.h in verification.c
verification.c had an include for jansson.h left over from previous
versions of the module.  Since res_stir_shaken no longer has a
dependency on jansson, the bundled version wasn't added to GCC's
include path so if you didn't also have a jansson development package
installed, the compile would fail.  Removing the stale include
was the only thing needed.

Resolves: #889
2024-09-26 10:38:47 -05:00
George Joseph
4d1ee54cf3 res_stir_shaken.c: Fix crash when stir_shaken.conf is invalid
* If the call to ast_config_load() returns CONFIG_STATUS_FILEINVALID,
check_for_old_config() now returns LOAD_DECLINE instead of continuing
on with a bad pointer.

* If CONFIG_STATUS_FILEMISSING is returned, check_for_old_config()
assumes the config is being loaded from realtime and now returns
LOAD_SUCCESS.  If it's actually not being loaded from realtime,
sorcery will catch that later on.

* Also refactored the error handling in load_module() a bit.

Resolves: #884
2024-09-26 10:38:27 -05:00
Asterisk Development Team
0dc0595f69 Update for 18.25.0-rc1 18.25.0-rc1 2024-09-12 18:44:42 +00:00
George Joseph
3575c02686 res_stir_shaken: Check for disabled before param validation
For both attestation and verification, we now check whether they've
been disabled either globally or by the profile before validating
things like callerid, orig_tn, dest_tn, etc.  This prevents useless
error messages.

Resolves: #879
(cherry picked from commit d010dd9752)
2024-09-12 18:44:38 +00:00
Tinet-mucw
8d3bd2cc31 app_chanspy.c: resolving the issue writing frame to whisper audiohook.
ChanSpy(${channel}, qEoSw): because flags set o, ast_audiohook_set_frame_feed_direction(audiohook, AST_AUDIOHOOK_DIRECTION_READ); this will effect whisper audiohook and spy audiohook, this makes writing frame to whisper audiohook impossible. So add function start_whispering to starting whisper audiohook.

Resolves: #876
(cherry picked from commit 03983b2ff9)
2024-09-12 18:44:38 +00:00
Alexei Gradinari
f435e28571 autoservice: Do not sleep if autoservice_stop is called within autoservice thread
It's possible that ast_autoservice_stop is called within the autoservice thread.
In this case the autoservice thread is stuck in an endless sleep.

To avoid endless sleep ast_autoservice_stop must check that it's not called
within the autoservice thread.

Fixes: #763
(cherry picked from commit 9b3d3a7f0e)
2024-09-12 18:44:38 +00:00
Jean-Denis Girard
beee92c909 app_voicemail: Fix sql insert mismatch caused by cherry-pick
When commit e8c9cb80 was cherry-picked in from master, the
fact that the 20 and 18 branches still had the old "macrocontext"
column wasn't taken into account so the number of named parameters
didn't match the number of '?' placeholders.  They do now.

We also now use ast_asprintf to create the full mailbox query SQL
statement instead of trying to calculate the proper length ourselves.

Resolves: #831
(cherry picked from commit 83b3783499)
2024-09-12 18:44:38 +00:00