Commit Graph
36266 Commits
Author SHA1 Message Date
Dmitry Verenitsin 0b4ff451e3 [mod_sofia] Pass deflect targets with a URI scheme through unchanged (#3210)
The deflect handler prefixed `sip:` and appended the profile address to any
target not starting with `sip:`. `tel:`, `sips:` and other URIs went out as
`sip:tel:...@<ip>`. A name-addr target, as a proxied `Refer-To` or
`${sip_refer_to}` passes it, went out as `sip:<sip:...>@<ip>`, or was not sent
at all when it carried a display name, URI params or `?Replaces=`.

`sofia_deflect_build_refer_to()` now builds the `Refer-To`:
- a target that has a URI scheme or contains `<` goes out as given
- `user@host`, with or without a host port, only gains the `sip:` scheme
- a bare user or number is addressed at the profile, as before
- an empty or `NULL` target, which the `deflect` app passes when run without
  data, is rejected; the handler logs it and sends no REFER

Adds `test_sofia_deflect_build_refer_to` to `test_sofia_funcs`: rejected
targets, bare users with IPv4 and IPv6 profile addresses, `user@host` forms,
URIs with a scheme, name-addr forms, the known limitations and truncation.
2026-11-18 23:35:18 +03:00
Dmitry Verenitsin 1da5eadf70 [mod_av, mod_openh264] Validate H.264 FU-A and H.263 packet lengths before depacketizing, add decoder unit tests (#3301) 2026-11-18 23:12:22 +03:00
Andrey Volk ef9417d45c Merge pull request #3300 from signalwire/dmitry/verto_null
[mod_verto] Namespace login userVariables and skip unnamed JSON members
2026-11-18 22:35:23 +03:00
Dmitry Verenitsin 39f5977a47 [mod_verto] Prefix login userVariables with verto_uvar_
Store `userVariables` sent in a `login` with a `verto_uvar_` prefix,
matching the `verto_dvar_` prefix per-call `dialogParams` userVariables
already carry, so the two scopes stay separate. Variables from the
user's directory `<variables>` block keep their names.

Dialplan that reads login variables by their unprefixed names needs
updating. The new per-profile `enable-uservars-namespace` turns the
prefix off for deployments that cannot do that yet; it defaults on.
2026-11-19 00:09:29 +05:00
Dmitry Verenitsin 898de5d1dd [mod_verto] Skip unnamed elements when reading client JSON members
`check_auth()` and `parse_user_vars()` copy the members of
`loginParams` and `userVariables` into events and channel variables,
but validated the member name on the string-value branch only. Check
it once at the top of each loop so every value type is handled the
same way.
2026-11-19 00:09:29 +05:00
Dmitry Verenitsin bc63ad6f89 [mod_verto] Release POST body and request state on HTTP error paths (#3299)
`http_run()` left the form-urlencoded POST body buffer allocated when
`kws_raw_read()` failed or the peer closed mid-body, up to
`HTTP_POST_MAX_BODY` per connection. Free it there, and clear
`keepalive` so the unread rest of the body is not parsed as the next
request.

The `err:` exit also freed neither `request` nor `stream.param_event`:
a header parse failure leaked the event, and a non-Basic
`Authorization` header leaked both. It now releases both, which makes
`request_err:` redundant, so its two users jump to `err:` instead.
2026-11-18 22:07:00 +03:00
Dmitry Verenitsin b5336ca3f9 [core] Cut switch_cut_path() at the last separator of either kind (#3298)
`switch_cut_path()` scanned for `/`, then restarted from the start of
the string for `\`, so whenever the last `\` came before the last `/`
the result still held `/`-separated components. Search for the last
`/` first, then for the last `\` in what follows it, so the result is
always what comes after the final separator, as documented.

Adds mixed-separator cases to
`test_switch_cut_path_strips_directory_components`.
2026-11-18 21:42:36 +03:00
Andrey Volk bb26953644 Merge pull request #3297 from signalwire/dmitry/msrp_fixes
[core] Fix MSRP buffer bounds, format handling and reachable asserts
2026-11-18 21:15:42 +03:00
Dmitry Verenitsin 74f63975fd [core] Do not start an MSRP client without a remote path
When the remote side offers `a=setup:passive`, negotiation started the
MSRP client whether or not the offer carried an `a=path`, and the
client then asserted on the missing `remote_path`. Start the client
only when a path was negotiated. In `msrp_worker()`, also stop with an
error instead of asserting when there is no path, and when the path
gives no host or port.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin 8721a8f654 [core] Harden MSRP message parsing and sending
- Reject a request with an empty transaction id, and a body that has
  no end-line delimiter to frame it.
- Keep the receive buffer NUL-terminated after every read.
- Free the setup message when an outbound connection fails before
  sending it.
- Refuse to send a message without a To-Path.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin 1dc4fd7df0 [core] Fix MSRP leaks and error handling in the worker
- Free MSRP messages and their headers on every path that drops
  them, including `uuid_msrp_send` and `mod_sofia`'s filtered text
  frames.
- Handle a failed `SSL_new()` and a call without an MSRP session by
  closing the connection instead of asserting.
- Treat a zero-length TLS read as the peer closing the connection.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin 44b8010ba5 [core] Bound the MSRP SEND request built in switch_msrp_do_send()
The request line and headers, the CRLF after the payload and the
end-line were written into the fixed stack buffer with `sprintf()`;
only the payload copy was checked, and the To-Path can be as long as
the remote SDP `a=path`. Build each part with `snprintf()` or a
checked copy, advance the length by what was written, and drop a
message that does not fit with an error log.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin d472a4cf6a [core] Remove the MSRP Byte-Range start assert
`msrp_parse_headers()` asserted that the received Byte-Range start was
above zero, so a range starting at 0 aborted the process. The payload
length derived from it is already checked against the declared total
and against the received data.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin eff3cc6f5e [core] Check for a missing To-Path before msrp_find_uuid() reads it
`msrp_find_uuid()` called `strlen()` on the To-Path before asserting
it was set, and a first SEND without a To-Path header passes NULL.
Return `SWITCH_FALSE` for it, so the worker handles it like any
To-Path that names no session.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin 93fe4cc929 [core] Treat the MSRP To-Path as data in msrp_find_uuid()
`msrp_find_uuid()` passed the tail of the received To-Path as the
format argument of `switch_snprintf()`. Pass it through `"%s"`.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin 108e7f1266 [core] Treat received MSRP header values as data, not a format
`msrp_parse_header()` and `msrp_parse_headers()` passed the received
header value as the format argument of `switch_msrp_msg_add_header()`,
so `%` sequences in it were interpreted. Pass it through `"%s"`; header
values containing `%` are now stored unchanged.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin b3871f4066 [core] Bound MSRP reply and report to their buffer
`msrp_reply()` and `msrp_report()` formatted the To-Path, From-Path,
Message-ID and delimiter of the received request into a 2048-byte
stack buffer with an unbounded `sprintf()`. Use `snprintf()` and send
nothing when the result does not fit, since a truncated reply would
lack its end-line.
2026-11-18 22:36:36 +05:00
Dmitry Verenitsin 68b340f5f5 [core] Confine MSRP remote file-selector name to the receive directory
Without an explicit path, `msrp_recv_file_function()` joined the
`sip_msrp_file_name` channel variable, taken from the remote SDP
`a=file-selector` name, onto the base directory unchanged, so a name
with directory components opened a file outside it. Reduce the name
to its last path component with `switch_cut_path()` and reject an
empty name, `.` and `..`.

`test_switch_cut_path_strips_directory_components` covers the path
reduction the receive path relies on.
2026-11-18 22:36:36 +05:00
Dmitry VerenitsinandAndrey Volk bffffa40a1 Merge commit from fork
Co-authored-by: Andrey Volk <andywolk@gmail.com>
2026-11-18 20:34:52 +03:00
Dmitry Verenitsin e4325bc8c1 Merge commit from fork
`amf0_data_read()` dispatched on the type byte into `amf0_object_read()`,
`amf0_associative_array_read()` and `amf0_array_read()`, each of which
called back into it for every contained element with nothing tracking
nesting depth. Chunk assembly admits up to `AMF_MAX_SIZE` bytes and a
nested object costs three of them per level, so one message can recurse
far deeper than `SWITCH_THREAD_STACKSIZE` holds.

Thread the depth through the dispatcher every arm funnels back into, so
one check covers any mix of them. A value past the cap is dropped, which
an object or ECMA array takes as its end and a strict array, having
declared an element count, takes as a failure. `amf0_data_read()` keeps
its signature and becomes a wrapper starting at depth 0. A cap of 32 sits
far above real traffic, where a `connect` command object nests two to
four levels.
2026-11-18 20:33:41 +03:00
Dmitry Verenitsin 2582f5cebd Merge commit from fork
A REFER with no call behind it is published as a `CALL_SETUP_REQ` event
whose `Request-Target` is `sofia/<profile>/<Refer-To URI>`, and
`mod_conference` hands that string to `switch_ivr_originate()` for
`rfc-4579` conferences. The URI was copied in unchanged, so a `,`, `|`
or `:_:` in it split the dial string into extra peers or legs, each of
which can start with its own `[...]` channel variables.

Answer such a REFER with `400 Bad Refer-To` before anything is
published. Both the serialized Refer-To and its user part are checked;
the user part is published separately as `Request-Target-Extension`,
which an `outcall-templ` expands. A Refer-To without these characters
is handled as before.

Also frees the subscription contact string an accepted REFER of this
kind allocated and never released.
2026-11-18 20:31:50 +03:00
Dmitry Verenitsin 382c669c93 Merge commit from fork
`conference_event_adv_la()` gave every live array member's
`event_channel_cookie` permission on the conference moderator channel,
the same as the live array, chat and info channels. On mod_verto that
permission is what lets a client broadcast to `conference-mod.*` and
run conference commands through
`conference_event_mod_channel_handler()`. Grant and revoke it only for
members with `MFLAG_MOD`, which does not change during membership, so
a participant call leaving does not strip it from a moderator call on
the same WebSocket.

Adds three `test_member` cases covering the participant, moderator and
shared-cookie grants on a new `livearray` test profile.
2026-11-18 20:30:30 +03:00
Dmitry Verenitsin 9606e32c55 Merge commit from fork
Run the display name and number through the same
`switch_clean_string()` and `switch_var_clean_string()` pass that
`profile_dup_clean()` applies when the profile is built from the
initial request, so a `${` in either is stored as `%{` whichever
message carried it.
2026-11-18 20:25:41 +03:00
Dmitry Verenitsin 512443322a Merge commit from fork
`switch_rtp_add_crypto_key()` allocated each MKI id buffer with
`sizeof(key_material->mki_size)`, a constant 4 bytes, then copied
`mki_size` bytes into it. That length comes from the remote `a=crypto`
attribute and was only checked against a lower bound. The same copy
read `mki_size` bytes starting at the 4-byte `mki_id` field.

Reject an MKI length outside 1..`SRTP_MAX_MKI_LEN`, allocate the id
buffer at that length, and copy no more than the width of `mki_id`,
leaving the remaining bytes zero. MKI lengths of 1 to 4 keep the bytes
they carry today.
2026-11-18 20:23:56 +03:00
Dmitry Verenitsin dec8abf635 Merge commit from fork
`get_rtt_red_seq()` stored one entry per RFC 2198 redundancy header
in the fixed `pt[]` and `len[]` arrays without checking the count
against `MAX_RED_FRAMES`, so a packet with more headers wrote past
them. Reject the packet once the count reaches `MAX_RED_FRAMES`, and
reject a frame index at or above it, which a sequence number wrap
can produce.
2026-11-18 20:22:48 +03:00
Dmitry Verenitsin 82adc771cb Merge commit from fork
`enum_app_function()` and `enum_api()` advanced their write cursor and
decremented the remaining space by `strlen(rp->route) + 1` rather than by
the bytes `switch_snprintf()` reported writing, so once a route no longer
fit the unsigned counter wrapped and the next iteration wrote past the end
of `rbuf` with no effective bound.

Both loops now share a `pack_routes()` helper that writes each route's
separator in front of it. Nothing points back into the buffer, so the
trailing-separator strip and its `rbuf[-1]` write are gone, along with the
write through a `char *` aimed at a string literal. A route that does not
fit whole, or that is empty, is skipped rather than clipped or ending the
loop.

`enum_app_function()` applies the same test when exporting `enum_route_N`,
so `enum_route_count` and the packed count describe the same routes: an
empty value would delete the variable rather than set it, leaving a gap in
the numbering. It also warns when the dial string ends up holding fewer
routes than were resolved, and `cnt`'s conversions are `%u` to match its
type.
2026-11-18 20:20:32 +03:00
Dmitry Verenitsin 0dcf2d7572 Merge commit from fork
`skinny_read_packet()` checked the declared length as `length + 8 >
2048` on a `uint32_t`, which wraps for lengths of `0xFFFFFFF8` and
above, and `skinny_check_data_length()` in the handlers only enforces a
minimum. Compare the length against the constant side instead, and
advance `ptr` on every read so a length field that arrives in pieces is
stored contiguously instead of being overwritten by later bytes.

- The message buffer gets one spare zero byte, so fixed-width string
  fields of a full-size message terminate inside the allocation.
- The data and extended data handlers check `data_length` against the
  bytes left after their header, with no addition on the wire value.
- Those two handlers and `skinny_handle_xml_alarm()` build the event
  body with `%.*s` instead of an unchecked `malloc` copy.
- `skinny_handle_extended_data_message()` takes the body from the
  `extended_data` member instead of `data`, so the event body no longer
  starts with 20 bytes of header fields.
- `skinny_handle_updatecapabilities()` rejects an empty audio
  capability list, as `skinny_handle_capabilities_response()` already
  does.
2026-11-18 20:19:42 +03:00
Dmitry Verenitsin fd911220be Merge commit from fork
On a profile with `extended-info-parsing` set, an inbound SIP INFO whose
content type is `freeswitch/api-request` puts an FSAPI command in the
request body and gets its output back in the 200 OK. The branch needs no
dialog, and no `mod_sofia` authentication or ACL setting covers an
out-of-dialog INFO. That same param also enables the in-dialog
`session-event` half, so there is no way to keep one and not the other.

The new per-profile `enable-info-api-request` param gates the api-request
branch alone and is off unless set, leaving `session-event` reachable
under `extended-info-parsing` as before. An INFO selecting the branch on a
profile without the new param is answered 403 and logged with the source
and the requested command; a permitted one is logged too, since the source
address appears in no event the API path fires. Both lines print the
body's first line, capped, rather than the whole body.
2026-11-18 20:18:00 +03:00
Andrey Volk 1fa330cafd [Core] RTP: stop using the libsrtp private API (#3292)
Use switch_rtp_hdr_t instead of srtp_hdr_t from srtp_priv.h, and srtp_shutdown() instead of srtp_crypto_kernel_shutdown(). Drop the rtp_hdr_t alias and add a compile-time check that switch_rtp_hdr_t is 12 bytes.
2026-11-17 23:14:38 +03:00
Andrey Volk 222d895954 [Build-System] Windows: Upgrade sqlite to v3.54.1_1 (#3294) 2026-11-17 21:08:00 +03:00
Andrey Volk 1af2909bb6 [mod_dialplan_xml] Fix $N substitution of <regex> captures (#3293)
Keep the subject string of a saved match alive and substitute only when a regex matched. Add unit-tests.
2026-11-17 15:35:58 +03:00
Andrey Volk f7ec023dc1 Merge pull request #3291 from signalwire/libnatpmp-dev
[Core] Remove in-tree libnatpmp: use libnatpmp-dev on Linux and the windows-deps package on Windows
2026-11-17 00:21:54 +03:00
Andrey Volk 9039d5a82d [libvpx] Update to v1.17.0-97-gd3335af9e (#3290)
* [libvpx] Update to v1.17.0-97-gd3335af9e

* [libvpx] Fix pthread configure checks: "Null pointer passed as an argument to a 'nonnull' parameter"

* [libvpx] Fix threading.
2026-11-16 23:42:06 +03:00
Andrey Volk 2baece4a5e [libvpx] Fix threading. 2026-11-16 23:18:46 +03:00
Andrey Volk 0b3e4644f2 [libvpx] Fix pthread configure checks: "Null pointer passed as an argument to a 'nonnull' parameter" 2026-11-16 23:18:46 +03:00
Andrey Volk a55111af58 [libvpx] Update to v1.17.0-97-gd3335af9e 2026-11-16 23:18:46 +03:00
Andrey Volk 7481baed18 [Core] Remove in-tree miniupnpc: use libminiupnpc-dev on Linux and the windows-deps package on Windows (#3289) 2026-11-16 23:18:14 +03:00
Andrey Volk 643efd444b [libyuv] Update to hash 79ca9187e540faaaca47b34622e110d07f335d05 from https://chromium.googlesource.com/libyuv/libyuv/ (#3288)
* [libyuv] Update to hash 79ca9187e540faaaca47b34622e110d07f335d05 from https://chromium.googlesource.com/libyuv/libyuv/

* [libyuv] Build AArch64 dotprod/i8mm/SVE/SME kernels with per-file -march to fix arm64/macOS build

* [libyuv] Fix build with GCC

HammingDistance_AVX512VNNI clobbers k1 but lacks the
LIBYUV_TARGET_AVX512VNNI attribute that its siblings use, so GCC on
x86_64 fails with "the register 'k1' cannot be clobbered in 'asm' for
the current target".

ARGBAlphaBlendRow_SVE_SC uses "mov z25.s, #0x01010101", which the GNU
assembler rejects as an invalid replicated MOV immediate. Use the
equivalent "mov z25.b, #1", which sets the same value and is accepted
by both GNU as and LLVM.

* [libyuv] Fix function declaration without a prototype

* [libyuv] Disable scan-build warnings.
2026-11-16 22:40:30 +03:00
Andrey Volk 1836c1f345 [libyuv] Disable scan-build warnings. 2026-11-16 21:58:33 +03:00
Andrey Volk b21fc93b78 [libyuv] Fix function declaration without a prototype 2026-11-16 21:58:33 +03:00
Andrey Volk 7f73f94c15 [libyuv] Fix build with GCC
HammingDistance_AVX512VNNI clobbers k1 but lacks the
LIBYUV_TARGET_AVX512VNNI attribute that its siblings use, so GCC on
x86_64 fails with "the register 'k1' cannot be clobbered in 'asm' for
the current target".

ARGBAlphaBlendRow_SVE_SC uses "mov z25.s, #0x01010101", which the GNU
assembler rejects as an invalid replicated MOV immediate. Use the
equivalent "mov z25.b, #1", which sets the same value and is accepted
by both GNU as and LLVM.
2026-11-16 21:58:33 +03:00
Andrey Volk 13fd84b33c [libyuv] Build AArch64 dotprod/i8mm/SVE/SME kernels with per-file -march to fix arm64/macOS build 2026-11-16 21:58:32 +03:00
Andrey Volk 379b73c3c3 [libyuv] Update to hash 79ca9187e540faaaca47b34622e110d07f335d05 from https://chromium.googlesource.com/libyuv/libyuv/ 2026-11-16 21:58:32 +03:00
Andrey Volk 07dedba4a4 [core] Replace GetARGBBlend with ARGBBlend in switch_img_patch_rgb and add a unit test, GetARGBBlend is removed from newer libyuv (#3287) 2026-11-16 21:54:28 +03:00
Andrey Volk 9b38dcf201 [Build-System] Windows: Update libpq to v17.11_3 (#3286) 2026-11-16 19:41:20 +03:00
Andrey Volk 0dd016319f [Build-System] Windows: Upgrade libnode to v24.22.3_1 (#3280) 2026-11-13 17:27:39 +03:00
Andrey Volk b791f28d01 [GHA] Move CI to Debian 13 (Trixie). (#3278)
Use the freeswitch-public-ci-base:trixie-amd64 image for unit-tests, D-in-D unit-tests and scan-build.
ci.sh: use scan-build-14 on bookworm and the default scan-build (clang 19) otherwise.
2026-11-09 23:03:18 +03:00
Andrey Volk fa67e000bf [mod_sofia] scan-build: sofia_receive_message(). Value stored to 'to_tag' during its initialization is never read (#3277) 2026-11-09 21:53:18 +03:00
Andrey Volk 9c48aa3f05 swigall (#3276) 2026-11-09 21:36:23 +03:00
Andrey Volk 75366730ac [SWIG] Generated files contain Dead initialization. Overload affected methods to avoid that. (#3275) 2026-11-09 21:08:00 +03:00