- Add patch from upstream to avoid division by 0 and other issues with invalid values (glfo#pipewire/pipewire#2953): * 0001-alsa-guard-against-some-invalid-values.patch - Add patch from upstream to fix causing an overflow resulting in choppy sound in some cases (glfo#pipewire/pipewire#2680): * 0001-spa-Fix-audioconvert-overflow-when-scaling.patch - Add patch from upstream to fix a crash on arm: * 0001-cpu-arm-Fix-incorrect-free.patch (glfo#pipewire/pipewire#2914) suspended, were kept suspended on a rate change. (glfo#pipewire/pipewire#2929) rates were allowed. (glfo#pipewire/pipewire#2925) (glfo#pipewire/pipewire#2891) properties. (glfo#pipewire/pipewire#2933) echo-cancel. (glfo#pipewire/pipewire#2939) (glfo#pipewire/pipewire#1599) fail. This caused problems for espeak. (glfo#pipewire/pipewire#2928) set to -1. (glfo#pipewire/pipewire#2893) OBS-URL: https://build.opensuse.org/request/show/1058858 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/pipewire?expand=0&rev=106
71 lines
2.3 KiB
Diff
71 lines
2.3 KiB
Diff
From 32a7c85c84e419636109eb5db127292e25462a38 Mon Sep 17 00:00:00 2001
|
|
From: Wim Taymans <wtaymans@redhat.com>
|
|
Date: Mon, 16 Jan 2023 16:05:17 +0100
|
|
Subject: [PATCH] alsa: guard against some invalid values
|
|
|
|
Avoid division by 0 and other strange things when invalid values
|
|
are detected.
|
|
|
|
Fixes #2953
|
|
---
|
|
spa/plugins/alsa/alsa-pcm.c | 22 ++++++++++++++++++++++
|
|
1 file changed, 22 insertions(+)
|
|
|
|
diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c
|
|
index 76fe433b8..08b9ceddd 100644
|
|
--- a/spa/plugins/alsa/alsa-pcm.c
|
|
+++ b/spa/plugins/alsa/alsa-pcm.c
|
|
@@ -1519,6 +1519,11 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
|
fmt->info.raw.rate = rrate;
|
|
match = false;
|
|
}
|
|
+ if (rchannels == 0 || rrate == 0) {
|
|
+ spa_log_error(state->log, "%s: invalid channels:%d or rate:%d",
|
|
+ state->props.device, rchannels, rrate);
|
|
+ return -EIO;
|
|
+ }
|
|
|
|
state->format = rformat;
|
|
state->channels = rchannels;
|
|
@@ -1563,6 +1568,11 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
|
|
|
CHECK(snd_pcm_hw_params_set_period_size_near(hndl, params, &period_size, &dir), "set_period_size_near");
|
|
|
|
+ if (period_size == 0) {
|
|
+ spa_log_error(state->log, "%s: invalid period_size 0 (driver error?)", state->props.device);
|
|
+ return -EIO;
|
|
+ }
|
|
+
|
|
state->period_frames = period_size;
|
|
|
|
if (state->default_period_num != 0) {
|
|
@@ -1578,6 +1588,10 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
|
CHECK(snd_pcm_hw_params_set_buffer_size_near(hndl, params, &state->buffer_frames), "set_buffer_size_near");
|
|
periods = state->buffer_frames / period_size;
|
|
}
|
|
+ if (state->buffer_frames == 0) {
|
|
+ spa_log_error(state->log, "%s: invalid buffer_frames 0 (driver error?)", state->props.device);
|
|
+ return -EIO;
|
|
+ }
|
|
|
|
state->headroom = state->default_headroom;
|
|
if (is_batch)
|
|
@@ -2542,6 +2556,14 @@ int spa_alsa_start(struct state *state)
|
|
state->duration = 1024;
|
|
state->rate_denom = state->rate;
|
|
}
|
|
+ if (state->rate_denom == 0) {
|
|
+ spa_log_error(state->log, "%s: unset rate_denom", state->props.device);
|
|
+ return -EIO;
|
|
+ }
|
|
+ if (state->duration == 0) {
|
|
+ spa_log_error(state->log, "%s: unset duration", state->props.device);
|
|
+ return -EIO;
|
|
+ }
|
|
|
|
state->following = is_following(state);
|
|
setup_matching(state);
|
|
--
|
|
GitLab
|
|
|