Commit graph

15378 commits

Author SHA1 Message Date
Barnabás Pőcze
b9bae7fdcf spa: alsa: pcm: spa_alsa_clear(): clear pointers
Use `spa_clear_ptr()` to ensure that all freed pointers are cleared.
2026-05-08 15:27:54 +00:00
Barnabás Pőcze
c8462edf4b spa: alsa: pcm: log_write(): return early if log level is disabled
If the "debug" log level is not enabled for the "spa.alsa" log topic,
then there is no point in going into the loop and splitting the data
into lines, so skip that.
2026-05-08 15:27:54 +00:00
Barnabás Pőcze
cfe9c7d6ca spa: alsa: pcm: log_write(): don't use strcspn()
Do not use `strcspn()` because it assumes a null terminated string,
but the `fopencookie()` write callback receives a (ptr, length) pair.

So use `memchr()` instead to find the `\n`.
2026-05-08 15:27:54 +00:00
Barnabás Pőcze
bba43d4433 spa: alsa: pcm: log_write(): fix return value
The `fopencookie()` write callback should return the number of consumed
bytes, but it currently only ever returns 0, which signals an error
condition according to the documentation.

Fix that by not overwriting `size`.

Fixes: 73073eb33f ("alsa: redirect alsa output to log file")
2026-05-08 15:27:54 +00:00
Barnabás Pőcze
ff7b996596 treewide: mark fopencookie() vtable const
`fopencookie()` takes the vtable by value, so it can be marked `const`, so do that.
2026-05-08 15:27:54 +00:00
Barnabás Pőcze
8caea521d7 doc: compile tutorial programs
The programs in `doc/examples` are not compiled currently, so let's
compile them if the `docs` and `examples` options don't disallow it.

`tutorial4.c` needs a small modification to avoid `-Wfloat-conversion`.

Additionally, install them if `installed_tests` is not disabled.
2026-05-08 15:20:41 +00:00
Wim Taymans
b5d294eab0 dfffile: handle invalid channels and rate
Missing or malformed headers could cause unspecified channels or rate
that can cause crashes.
2026-05-08 17:12:54 +02:00
Wim Taymans
57770c7e18 midifile: handle some other read errors 2026-05-08 17:07:51 +02:00
Wim Taymans
c94bbb55bc midifile: read up to 4 bytes for the varlen 2026-05-08 17:00:56 +02:00
Martin Geier
c7f2f0dc73 audioconvert: update rate also for nodes with disabled resampler
When the graph rate changes it is possible that the follower node can
renegotiate to the new suggested audioconvert rate without requiring
resampling and so the extra check for the disabled resampler is not
required.

Fixes #4933
2026-05-08 15:56:05 +02:00
Wim Taymans
4c8093fa72 combine-stream: clean up some variables
Move the source offs, stride, data and size calculations out of the
destination loop. We only need to clamp the size to copy to the maxsize
of the destination buffer.
2026-05-08 13:10:30 +02:00
Wim Taymans
93b940edef module-combine: limit size to buffer maxsize
Limit the amount of data we write to the destination buffer to its
maxsize.
2026-05-08 13:01:11 +02:00
Wim Taymans
136fc59765 bluez5: avoid heap overflow in AAC decoder
aacDecoder_DecodeFrame expects the number of destination INT_PCM samples,
not bytes. Since INT_PCM is int16_t (2 bytes), passing dst_size in bytes
tells the decoder the buffer is 2x larger than reality.

Note that we don't need to care about the number of channels in this
size, the decoder will do that for us.
2026-05-08 13:01:03 +02:00
Wim Taymans
6d3122c1b1 sap: avoid reading past the end of the string
parse_sdp_a_rtpmap used c += strlen(c) + 1 to skip past the MIME type to the
rate/channels part, but if the a=rtpmap: line had no / separator, strcspn
returned the full string length and the +1 advanced past the null terminator.

Fix this by checking if / was actually found, returning -EINVAL if not.
2026-05-08 11:57:07 +02:00
Wim Taymans
7fd3e13a3e netjack2: handle 0 in sync frames
JACK2 only sends -1 as the frames, meaning we should take the value from
the negotiated period as the frames to process.

We however send the actual number of frames and use the sync value to
decide how many frames to process. We need to be careful because a value
of 0 will cause a division by 0 so treat <= 0 frames the negotiated period
size as well.
2026-05-08 11:42:15 +02:00
Wim Taymans
753eae9302 netjack2: check config against MAX_CHANNELS
Check that the params don't include more than MAX_CHANNELS of audio or
else we overflow the position array.

Adapt to the compiled value of SPA_AUDIO_MAX_CHANNELS but allow at least
128 channels.
2026-05-08 11:07:03 +02:00
Wim Taymans
6cee86e509 sendspin: avoid buffer overread
Check that we have enough bytes (>=9) to parse the message type and the
timestamp.
2026-05-08 10:33:39 +02:00
Wim Taymans
22243d5ce9 sendspin: handle parse_player errors
Otherwise, this might leave the stride 0 and cause a division by 0
later.
2026-05-08 10:32:28 +02:00
Wim Taymans
5b37b9cf99 filter-graph: remove the pipe filter
It's a terrible idea, doesn't work so well (locks up the data-loop when
read is blocked) and a security mightmare. If you really need to pipe
samples through some program, do that somewhere else, like from the
command line with pw-cat and pw-record.
2026-05-08 10:16:12 +02:00
Wim Taymans
b3257ae425 context: add library.use-fallback option
Normally, when loading a plugin feature, often a library.name property
is given as well. If the feature to load is not explicitly listed in
context.spa-libs, the library.name is used a fallback library.

Add an option to ignore this library.name and only use the
context.spa-libs entries. This makes it possible to only load explicitly
listed features in the config file and makes it possible to lock down
what plugins can be loaded.

Set the option to true by default for now, which keeps the existing
behaviour of using the fallback library. Add some more entries to the
context.spa-libs in case the option is switched off to make things
work.

Set the option to false for the minimal.conf.
2026-05-08 09:57:52 +02:00
Barnabás Pőcze
ddab12a5aa bluez5: cancel RegisterApplication calls when adapter goes away
If an adapter's removal is processed before the pending `RegisterApplication()`
dbus calls return, then those pending calls are not cancelled, and when the
(error) replies arrive, the callbacks will run into use-after-free issues
since they reference the removed adapter.

See #5096
2026-05-08 07:11:52 +00:00
Wim Taymans
97c8a0a5ae modules: update docs for the pipe plugin 2026-05-07 14:46:21 +02:00
Wim Taymans
85decefbef filter-graph: move the pipe plugin to separate .so
It's quite dangerous to allow it to be loaded dynamically into the
pulse server so block it. The other plugins should be safe to load.
2026-05-07 14:37:44 +02:00
Wim Taymans
a4e2856d06 pulse-server: block arbitrary filter-graphs
Add a special 'blocked' spa-libs value that returns EPERM when trying to
load the factory.

Only allow loading the LADSPA filter.graph nodes for the LADSPA sink and
source. The most problematic part is the pipe filter, that allows it to
spawn arbirary programs as part of the filter.graph.

You can add a filter-graph to any stream with stream_props.
2026-05-07 14:13:38 +02:00
Wim Taymans
e3f75314be vban: fix timestamp overflows
Like how it is done in RTP.
2026-05-07 14:07:33 +02:00
Wim Taymans
143af979ab filter-graph: error when there are no valid nodes
The nodes might have failed to load or there was an empty array or the
array did not contain objects.
2026-05-07 13:30:41 +02:00
Wim Taymans
e9aff3040a modules: free the stream and impl on errors 2026-05-07 13:30:12 +02:00
Wim Taymans
aa36fd5a17 pulse-server: avoid double free of props
Use spa_steal_ptr to transfer props ownership when we can.

This fixes a problem in the upload stream where the props would be freed
twice when buffer allocation failed, once with properties_free and
then with stream_free.
2026-05-07 10:30:35 +02:00
Wim Taymans
e975a44d05 modules: handle more stream setup failures
Instead of silently ignoring things.
2026-05-06 16:23:08 +02:00
Wim Taymans
9825fb3647 impl-link: use the right port direction string
We might swap input and output so make sure we use the right one in the
debug log to avoid confusion.
2026-05-06 16:21:07 +02:00
Wim Taymans
c362bca5e9 loopback: handle stream setup failure
Instead of silently failing.
Also when we do the cleanup, make sure we don't free the props twice.
2026-05-06 16:07:59 +02:00
Wim Taymans
eadaa2608a alsa: clear output and log file after doing alsa API
Also be a bit more careful when the handles are NULL.
2026-05-06 16:05:30 +02:00
Wim Taymans
91755950dd spa: improve error handling
Use impl_clear to clean up partially allocated handles. Make sure we
only clean up the initialized parts.
2026-05-06 14:20:52 +02:00
Wim Taymans
3e53487c72 bluez5: fix cleanup
Clean up the transport listener and the codec_props on error.
Also clean up when the timerfd allocation fails.
2026-05-06 14:03:18 +02:00
Wim Taymans
7254b8288f alsa: clean up the impl on errors 2026-05-06 13:59:43 +02:00
Wim Taymans
517b6c3778 jack: handle get_registry failure 2026-05-06 13:54:19 +02:00
Wim Taymans
95a4772031 modules: handle get_registry NULL return value 2026-05-06 13:50:02 +02:00
Wim Taymans
ac95f1241e modules: fix portal error handling
Mostly to fix the property cleanup.
2026-05-06 13:48:35 +02:00
Wim Taymans
51b635cc98 modules: convert snprintf to strbuf
Use spa_strbuf instead of snprintf to handle errors better.
2026-05-06 13:35:09 +02:00
Wim Taymans
2c4dc2d22f raop: handle loop_add_io errors 2026-05-06 13:18:11 +02:00
Wim Taymans
cc2c7cc591 modules: handle some property allocation errors 2026-05-06 13:17:41 +02:00
Wim Taymans
b66614063d avb: use safer strbuf to construct strings 2026-05-06 13:09:03 +02:00
Wim Taymans
8276d615ba filter-graph: handle fcntl errors better
Don't set invalid flags when the F_GETFL failed.
2026-05-06 12:47:44 +02:00
Wim Taymans
fed4d14ab7 vulkan: check for fcntl errors 2026-05-06 12:45:37 +02:00
Wim Taymans
f5bbdc403f profiler: fix cleanup on errors
Make an impl_destroy function to clean up partially initialized impl.
Handle failed flush_event allocation. Handle all errors in one place.
2026-05-06 12:39:39 +02:00
Wim Taymans
aac0f13487 module-echo-cancel: fix cleanup
Go to the error label to make sure verything is cleaned up properly when
loading the aec plugin fails for some reason.
2026-05-06 12:27:09 +02:00
Wim Taymans
d33466a340 bluez5: fix wrong use of F_GETFL and F_SETFL
The pattern is to F_GETFL the flags, then clear the NONBLOCK flag and
then F_SETFL the new flags.
2026-05-06 12:22:39 +02:00
Wim Taymans
195c048d1c audioconvert: use strbuf to construct the channel names
This handles overflow and errors correctly, unlike snprintf which might
return -1 or the size that would have been written if truncated, causing
overwrite later.
2026-05-06 11:57:52 +02:00
Wim Taymans
bceaf1a212 vulkan: handle mmap failure 2026-05-06 11:57:52 +02:00
Wim Taymans
59a5392850 vulkan: fix the open() flags
The second argument are the flags, the mode is not needed for
RDONLY. Accidentally works because O_RDONLY is 0 but ignored the
O_CLOEXEC flags.
2026-05-06 11:57:52 +02:00