pipewire/spa/plugins/audioconvert
Barnabás Pőcze 8c892443eb spa: audioadapter: fix stack-use-after-scope when configuring format
It is not enough for `buffer` to be alive in its current
scope because when execution enters that branch, `format`
will be set to `fmt`, which points inside `buffer`. And
since `format` is used outside that scope, `buffer` must
live longer.

This was detected by ASAN when Audacity was starting up.

  ==25007==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffdbcfef560 at pc 0x7fe44ca95db3 bp 0x7ffdbcfeeda0 sp 0x7ffdbcfeed90
  READ of size 4 at 0x7ffdbcfef560 thread T0
      #0 0x7fe44ca95db2 in spa_pod_parser_pod ../spa/include/spa/pod/parser.h:67
      #1 0x7fe44ca9a805 in spa_format_parse ../spa/include/spa/param/format-utils.h:44
      #2 0x7fe44cad293a in port_set_format ../spa/plugins/audioconvert/audioconvert.c:1934
      #3 0x7fe44cadad14 in impl_node_port_set_param ../spa/plugins/audioconvert/audioconvert.c:2038
      #4 0x7fe44ca587e2 in configure_format ../spa/plugins/audioconvert/audioadapter.c:509
      #5 0x7fe44ca60dff in negotiate_format ../spa/plugins/audioconvert/audioadapter.c:822
      #6 0x7fe44ca62bbf in impl_node_send_command ../spa/plugins/audioconvert/audioadapter.c:846
      #7 0x7fe45ea1c2f1 in node_update_state ../src/pipewire/impl-node.c:407
      #8 0x7fe45ea5137e in pw_impl_node_set_state ../src/pipewire/impl-node.c:2251
      #9 0x7fe45eb3355f in pw_work_queue_destroy ../src/pipewire/work-queue.c:142
      #10 0x7fe45b2cd6f4 in source_event_func ../spa/plugins/support/loop.c:615
      #11 0x7fe45b2c634f in loop_iterate ../spa/plugins/support/loop.c:452
      #12 0x7fe45e9ebebc in spa_hook_list_clean ../spa/include/spa/utils/hook.h:395
      #13 0x5561e03dc722 in main ../src/daemon/pipewire.c:131
      #14 0x7fe45da3c28f  (/usr/lib/libc.so.6+0x2328f)
      #15 0x7fe45da3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
      #16 0x5561e03db2a4 in _start ../sysdeps/x86_64/start.S:115

  Address 0x7ffdbcfef560 is located in stack of thread T0 at offset 160 in frame
      #0 0x7fe44ca56fa9 in configure_format ../spa/plugins/audioconvert/audioadapter.c:475

    This frame has 4 object(s):
      [32, 36) 'state' (line 493)
      [48, 56) 'fmt' (line 494)
      [80, 128) 'b' (line 492)
      [160, 4256) 'buffer' (line 491) <== Memory access at offset 160 is inside this variable
2022-12-10 09:59:08 +00:00
..
audioadapter.c spa: audioadapter: fix stack-use-after-scope when configuring format 2022-12-10 09:59:08 +00:00
audioconvert.c audioconvert: fix PortConfig enumeration 2022-12-05 09:15:48 +01:00
benchmark-fmt-ops.c spa: add macro to simplify array iterations some more 2022-09-30 16:24:26 +02:00
benchmark-resample.c audioconvert tests: Default to using an installed libspa-support 2020-09-14 18:16:49 +00:00
biquad.c audioconvert: build C versions with -Ofast and -ffast-math 2022-07-14 10:07:07 +02:00
biquad.h Fix typos 2021-04-30 16:27:34 +00:00
channelmix-ops-c.c channelmix: optimize some more nXm cases 2022-09-29 13:21:23 +02:00
channelmix-ops-sse.c audioconvert: optimize upmix functions with SSE 2022-10-13 10:19:04 +02:00
channelmix-ops.c audioconvert: skip upmix when moving channels 2022-11-09 09:24:03 +01:00
channelmix-ops.h audioconvert: optimize upmix functions with SSE 2022-10-13 10:19:04 +02:00
crossover.c audioconvert: build C versions with -Ofast and -ffast-math 2022-07-14 10:07:07 +02:00
crossover.h channelmix: improve corssover processing 2022-03-01 09:08:17 +01:00
delay.h audioconvert: add delay to rear channels when upmixing 2022-03-01 09:56:12 +01:00
fmt-ops-avx2.c audioconvert: improve some more AVX2 code 2022-12-05 09:37:29 +01:00
fmt-ops-c.c audioconvert: make separate noise functions 2022-09-29 21:36:06 +02:00
fmt-ops-neon.c audioconvert: fix rounding on arm neon 2022-07-21 17:24:55 +02:00
fmt-ops-sse2.c audioconvert: make separate noise functions 2022-09-29 21:36:06 +02:00
fmt-ops-sse41.c audioconvert: simplify 24 bits handling 2022-07-01 12:25:58 +02:00
fmt-ops-ssse3.c audioconvert: simplify 24 bits handling 2022-07-01 12:25:58 +02:00
fmt-ops.c spa: add macro to simplify array iterations some more 2022-09-30 16:24:26 +02:00
fmt-ops.h spa: add macro to simplify array iterations some more 2022-09-30 16:24:26 +02:00
hilbert.h audioconvert: add optional hilbert transform to rear channels 2022-03-01 11:09:43 +01:00
law.h audioconvert: add converstion to and from alaw/ulaw 2021-08-17 17:32:25 +02:00
meson.build audioconvert: add peaks test 2022-09-27 12:14:43 +02:00
peaks-ops-c.c audioconvert: move peaks functions to separate file 2022-09-27 11:25:02 +02:00
peaks-ops-sse.c audioconvert: move peaks functions to separate file 2022-09-27 11:25:02 +02:00
peaks-ops.c spa: add macro to simplify array iterations some more 2022-09-30 16:24:26 +02:00
peaks-ops.h audioconvert: move peaks functions to separate file 2022-09-27 11:25:02 +02:00
plugin.c audioconvert2: rename to audioconvert 2022-06-16 09:19:05 +02:00
resample-native-avx.c audioconvert: refactor peaks resampler 2022-09-07 16:00:31 +02:00
resample-native-c.c audioconvert: refactor peaks resampler 2022-09-07 16:00:31 +02:00
resample-native-impl.h resample: cleanup the resampler core functions 2022-11-20 16:19:24 +01:00
resample-native-neon.c audioconvert: refactor peaks resampler 2022-09-07 16:00:31 +02:00
resample-native-sse.c audioconvert: refactor peaks resampler 2022-09-07 16:00:31 +02:00
resample-native-ssse3.c audioconvert: refactor peaks resampler 2022-09-07 16:00:31 +02:00
resample-native.c Fix various compiler warnings 2022-10-06 12:12:35 -04:00
resample-peaks.c audioconvert: move peaks functions to separate file 2022-09-27 11:25:02 +02:00
resample.h audioconvert: add resample.prefill option 2022-09-19 12:35:49 +02:00
spa-resample.c spa-resample: don't flush too much 2022-07-13 12:02:12 +02:00
test-audioadapter.c audioadapter: add support for passthrough mode 2021-08-17 16:01:10 +00:00
test-audioconvert.c test: add test for 6p1 to 5p1 with remapped REAR 2022-11-09 09:41:21 +01:00
test-channelmix.c test: avoid compiler warnings when SSE is not enabled 2022-11-11 12:09:22 +01:00
test-fmt-ops.c audioconvert: fix rounding on arm neon 2022-07-21 17:24:55 +02:00
test-helper.h tests: fix some leaks 2020-12-21 20:07:02 +01:00
test-peaks.c audioconvert: add peaks test 2022-09-27 12:14:43 +02:00
test-resample.c test: replace all spa_assert() macros with spa_assert_se() 2021-07-27 10:24:44 +10:00
test-source.c Add some more format checks 2022-11-03 13:10:32 +01:00
volume-ops-c.c audioconvert: add volume ops 2021-02-05 15:08:26 +01:00
volume-ops-sse.c audioconvert: add volume ops 2021-02-05 15:08:26 +01:00
volume-ops.c spa: add macro to simplify array iterations some more 2022-09-30 16:24:26 +02:00
volume-ops.h audioconvert: expose the selected function names 2022-06-28 16:50:14 +02:00