Accepting request 1137523 from home:tiwai:branches:multimedia:libs

- Backport upstream fixes:
  buffer overflow fixes in aplay, segfault in aplaymidi, etc:
  0008-topology-include-locale.h.patch 
  0009-nhlt-dmic-info.c-include-sys-types.h.patch 
  0010-topology-pre-processor-Add-support-for-enum-controls.patch 
  0011-configure.ac-fix-UMP-support-detection.patch 
  0012-bat-really-skip-analysis-of-the-first-period-and-upd.patch 
  0013-topology-add-include-for-ENABLE_NLS-on-musl.patch 
  0014-nhlt-use-stdint.h-types.patch 
  0015-Revert-nhlt-dmic-info.c-include-sys-types.h.patch 
  0016-aplay-use-stdint.h-types-instead-u_int-u_short-u_cha.patch 
  0017-alsa-restore.rules-use-devnode-instead-number-atribu.patch 
  0018-nhlt-Revert-SSP_ANALOG-device_type-field.patch 
  0019-alsactl-fix-potential-buffer-overwrite.patch 
  0020-aplay-fix-buffer-overflow-and-tainted-format-string.patch 
  0021-misc-fix-incorrect-usages-of-strerror.patch 
  0022-aplay-Add-option-for-specifying-subformat.patch 
  0023-aplay-allow-to-compile-with-older-alsa-lib-subformat.patch 
  0024-aplay-log-pcm-status-before-reporting-a-fatal-error.patch 
  0025-aplay-enable-timestamps-by-default.patch 
  0026-aplay-status-dumps-are-called-only-in-verbose-mode.patch 
  0027-aplaymidi-Set-event-completely-for-tempo-event.patch

OBS-URL: https://build.opensuse.org/request/show/1137523
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa-utils?expand=0&rev=210
This commit is contained in:
Takashi Iwai 2024-01-08 12:04:12 +00:00 committed by Git OBS Bridge
parent 9ba2362df1
commit c349a7f6d8
22 changed files with 1557 additions and 2 deletions

View File

@ -0,0 +1,29 @@
From 8c229270f6bae83b705a03714c46067a7aa57b02 Mon Sep 17 00:00:00 2001
From: Michael Opdenacker <michael.opdenacker@bootlin.com>
Date: Tue, 19 Sep 2023 13:14:29 +0200
Subject: [PATCH] topology: include locale.h
This solves an issue compiling with the musl libc.
Fixes: https://github.com/alsa-project/alsa-utils/issues/239
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
topology/topology.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/topology/topology.c b/topology/topology.c
index 1840ffe65cba..5d03a8b133b8 100644
--- a/topology/topology.c
+++ b/topology/topology.c
@@ -32,6 +32,7 @@
#include <sys/stat.h>
#include <getopt.h>
#include <assert.h>
+#include <locale.h>
#include <alsa/asoundlib.h>
#include <alsa/topology.h>
--
2.35.3

View File

@ -0,0 +1,29 @@
From 0925ad7f09b2dc77015784f9ac2f5e34dd0dd5c3 Mon Sep 17 00:00:00 2001
From: Michael Opdenacker <michael.opdenacker@bootlin.com>
Date: Tue, 19 Sep 2023 13:14:30 +0200
Subject: [PATCH] nhlt-dmic-info.c: include sys/types.h
This fixes an issue compiling with the musl libc.
Fixes: https://github.com/alsa-project/alsa-utils/issues/238
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
nhlt/nhlt-dmic-info.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/nhlt/nhlt-dmic-info.c b/nhlt/nhlt-dmic-info.c
index 3f6c64d992b9..331555a82677 100644
--- a/nhlt/nhlt-dmic-info.c
+++ b/nhlt/nhlt-dmic-info.c
@@ -33,6 +33,7 @@
#include <fcntl.h>
#include <getopt.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <arpa/inet.h>
int debug = 0;
--
2.35.3

View File

@ -0,0 +1,124 @@
From 68dd54784a0b2287015433a62600b28bbff49399 Mon Sep 17 00:00:00 2001
From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Date: Mon, 11 Sep 2023 08:18:15 -0700
Subject: [PATCH] topology: pre-processor: Add support for enum controls
Add support for adding enum controls in the topology pre-processor.
Closes: https://github.com/alsa-project/alsa-utils/pull/236
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
topology/pre-process-dapm.c | 26 ++++++++++++++++++++++++++
topology/pre-process-object.c | 14 +++++++++++++-
topology/pre-processor.h | 4 ++++
3 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/topology/pre-process-dapm.c b/topology/pre-process-dapm.c
index 9355a861757d..78944a6d9801 100644
--- a/topology/pre-process-dapm.c
+++ b/topology/pre-process-dapm.c
@@ -70,6 +70,26 @@ int tplg_build_channel_object(struct tplg_pre_processor *tplg_pp, snd_config_t *
return tplg_build_base_object(tplg_pp, obj_cfg, parent, false);
}
+int tplg_build_text_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+ snd_config_t *parent)
+{
+ snd_config_t *cfg;
+ const char *name;
+ int ret;
+
+ cfg = tplg_object_get_instance_config(tplg_pp, obj_cfg);
+
+ name = tplg_object_get_name(tplg_pp, cfg);
+ if (!name)
+ return -EINVAL;
+
+ ret = tplg_build_object_from_template(tplg_pp, obj_cfg, &cfg, NULL, false);
+ if (ret < 0)
+ return ret;
+
+ return tplg_parent_update(tplg_pp, parent, "texts", name);
+}
+
int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
snd_config_t *parent)
{
@@ -131,6 +151,12 @@ int tplg_build_bytes_control(struct tplg_pre_processor *tplg_pp, snd_config_t *o
return tplg_build_control(tplg_pp, obj_cfg, parent, "bytes");
}
+int tplg_build_enum_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+ snd_config_t *parent)
+{
+ return tplg_build_control(tplg_pp, obj_cfg, parent, "enum");
+}
+
/*
* Widget names for pipeline endpoints can be of the following type:
* "class.<constructor args separated by .> ex: pga.0.1, buffer.1.1 etc
diff --git a/topology/pre-process-object.c b/topology/pre-process-object.c
index 61cc85fbc43d..34b92033435c 100644
--- a/topology/pre-process-object.c
+++ b/topology/pre-process-object.c
@@ -117,7 +117,7 @@ int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
return ret;
/* get section config */
- if (!strcmp(section_name, "tlv")) {
+ if (!strcmp(section_name, "tlv") || !strcmp(section_name, "texts")) {
/* set tlv name if config exists already */
ret = snd_config_search(cfg, section_name, &item_config);
if (ret < 0) {
@@ -1038,6 +1038,15 @@ const struct config_template_items bytes_control_config = {
.compound_config_ids = {"access"}
};
+const struct config_template_items enum_control_config = {
+ .int_config_ids = {"index"},
+ .compound_config_ids = {"access"}
+};
+
+const struct config_template_items text_config = {
+ .compound_config_ids = {"values"}
+};
+
const struct config_template_items scale_config = {
.int_config_ids = {"min", "step", "mute"},
};
@@ -1073,6 +1082,7 @@ const struct build_function_map object_build_map[] = {
{"Base", "ops", "ops" ,&tplg_build_ops_object, NULL, &ops_config},
{"Base", "extops", "extops" ,&tplg_build_ops_object, NULL, &ops_config},
{"Base", "channel", "channel", &tplg_build_channel_object, NULL, &channel_config},
+ {"Base", "text", "SectionText", &tplg_build_text_object, NULL, &text_config},
{"Base", "VendorToken", "SectionVendorTokens", &tplg_build_vendor_token_object,
NULL, NULL},
{"Base", "hw_config", "SectionHWConfig", &tplg_build_hw_cfg_object, NULL,
@@ -1085,6 +1095,8 @@ const struct build_function_map object_build_map[] = {
&mixer_control_config},
{"Control", "bytes", "SectionControlBytes", &tplg_build_bytes_control, NULL,
&bytes_control_config},
+ {"Control", "enum", "SectionControlEnum", &tplg_build_enum_control, NULL,
+ &enum_control_config},
{"Dai", "", "SectionBE", &tplg_build_generic_object, NULL, &be_dai_config},
{"PCM", "pcm", "SectionPCM", &tplg_build_generic_object, NULL, &pcm_config},
{"PCM", "pcm_caps", "SectionPCMCapabilities", &tplg_build_pcm_caps_object,
diff --git a/topology/pre-processor.h b/topology/pre-processor.h
index 878653d4c849..3a8a4bc3b1a8 100644
--- a/topology/pre-processor.h
+++ b/topology/pre-processor.h
@@ -70,6 +70,10 @@ int tplg_build_mixer_control(struct tplg_pre_processor *tplg_pp, snd_config_t *o
snd_config_t *parent);
int tplg_build_bytes_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
snd_config_t *parent);
+int tplg_build_enum_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+ snd_config_t *parent);
+int tplg_build_text_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+ snd_config_t *parent);
int tplg_build_dapm_route_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
snd_config_t *parent);
int tplg_build_hw_cfg_object(struct tplg_pre_processor *tplg_pp,
--
2.35.3

View File

@ -0,0 +1,38 @@
From 31e91f911e9132171a87fb7966c3f4701ff9717c Mon Sep 17 00:00:00 2001
From: Bernd Kuhls <bernd@kuhls.net>
Date: Fri, 13 Oct 2023 20:32:32 +0200
Subject: [PATCH] configure.ac: fix UMP support detection
https://github.com/alsa-project/alsa-utils/commit/b399fb85a919636b7da34e8bcf17f484dd9046f7
added usage of alsa/ump_msg.h without checking whether alsa-lib was
compiled with rawmidi support:
https://github.com/alsa-project/alsa-lib/blob/master/include/Makefile.am#L37
Fixes a build error when alsa-lib was compiled with --disable-rawmidi
aplaymidi.c:34:10: fatal error: alsa/ump_msg.h: No such file or directory
34 | #include <alsa/ump_msg.h>
Closes: https://github.com/alsa-project/alsa-utils/pull/240
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index beb496393df5..42177416dafe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ if test "$HAVE_SEQ_CLIENT_INFO_GET_PID" = "yes" ; then
AC_DEFINE([HAVE_SEQ_CLIENT_INFO_GET_PID], 1, [alsa-lib supports snd_seq_client_info_get_pid])
fi
AC_CHECK_LIB([asound], [snd_seq_client_info_get_midi_version], [HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION="yes"])
-if test "$HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION" = "yes" ; then
+if test "$HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION" = "yes" -a "$have_rawmidi" = "yes"; then
AC_DEFINE([HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION], 1, [alsa-lib supports snd_seq_client_info_get_midi_version])
fi
AC_CHECK_LIB([atopology], [snd_tplg_save], [have_topology="yes"], [have_topology="no"])
--
2.35.3

View File

@ -0,0 +1,44 @@
From 039e4cad48a01437d195914b57b5da83ebc582c3 Mon Sep 17 00:00:00 2001
From: Delio Brignoli <dbrignoli@audioscience.com>
Date: Mon, 18 Sep 2023 09:33:37 +0100
Subject: [PATCH] bat: really skip analysis of the first period and update
related comment
Prior to this change bat/analyze.c would skip the last period of the recording, contrary to
what the comment in the code which stated the first period was meant to be skipped.
The comment has been updated to state that both the first and last period are skipped and the code
has been updated to match.
Closes: https://github.com/alsa-project/alsa-utils/pull/237
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
bat/analyze.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bat/analyze.c b/bat/analyze.c
index 686788000f99..b8d02706fe66 100644
--- a/bat/analyze.c
+++ b/bat/analyze.c
@@ -299,7 +299,7 @@ static int calculate_noise(struct bat *bat, float *src, int channel)
/* each section has 2 sine periods, the first one for locating
* and the second one for noise calculating */
int nsamples_per_section = nsamples * 2;
- /* all sine periods will be calculated except the first one */
+ /* all sine periods will be calculated except the first and last one */
int nsection = bat->frames / nsamples - 1;
fprintf(bat->log, _("samples per period: %d\n"), nsamples);
@@ -331,7 +331,7 @@ static int calculate_noise(struct bat *bat, float *src, int channel)
/* calculate average noise level */
sum_snr_pc = 0.0;
cnt_clean = cnt_noise = 0;
- for (i = 0, offset = 0; i < nsection; i++) {
+ for (i = 1, offset = nsamples; i < nsection; i++) {
na.snr_db = SNR_DB_INVALID;
err = calculate_noise_one_period(bat, &na, src + offset,
--
2.35.3

View File

@ -0,0 +1,39 @@
From d272c5d935b2ff8acc00f16317f1f960b02ed3a1 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Thu, 7 Sep 2023 21:23:51 +0100
Subject: [PATCH] topology: add include for ENABLE_NLS on musl
Needed for setlocale().
(After rebasing to pick up 8c229270f6bae83b705a03714c46067a7aa57b02, just
move it to be guarded as the include now exists.)
Closes: https://github.com/alsa-project/alsa-utils/pull/234
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
topology/topology.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/topology/topology.c b/topology/topology.c
index 5d03a8b133b8..98b000aa5031 100644
--- a/topology/topology.c
+++ b/topology/topology.c
@@ -32,11 +32,13 @@
#include <sys/stat.h>
#include <getopt.h>
#include <assert.h>
-#include <locale.h>
#include <alsa/asoundlib.h>
#include <alsa/topology.h>
#include "gettext.h"
+#ifdef ENABLE_NLS
+#include <locale.h>
+#endif
#include "version.h"
#include "topology.h"
--
2.35.3

View File

@ -0,0 +1,109 @@
From c08d580b281bd5965585bf09b45ba3a582202931 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Thu, 7 Sep 2023 21:24:16 +0100
Subject: [PATCH] nhlt: use stdint.h types
u_int_* aren't standard, but uint* are. Use those instead for musl compat.
Closes: https://github.com/alsa-project/alsa-utils/pull/234
Bug: https://bugs.gentoo.org/913758
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
nhlt/nhlt-dmic-info.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/nhlt/nhlt-dmic-info.c b/nhlt/nhlt-dmic-info.c
index 331555a82677..eadf21a11bbc 100644
--- a/nhlt/nhlt-dmic-info.c
+++ b/nhlt/nhlt-dmic-info.c
@@ -46,7 +46,7 @@ int debug = 0;
#define NHLT_EP_HDR_SIZE (4 + 1 + 1 + 2 + 2 + 2 + 4 + 1 + 1 + 1)
#define VENDOR_MIC_CFG_SIZE (1 + 1 + 2 + 2 + 2 + 1 + 1 + 2 + 2 + 2 + 2 + 2 + 2)
-static const char *microphone_type(u_int8_t type)
+static const char *microphone_type(uint8_t type)
{
switch (type) {
case 0: return "omnidirectional";
@@ -60,7 +60,7 @@ static const char *microphone_type(u_int8_t type)
return "unknown";
}
-static const char *microphone_location(u_int8_t location)
+static const char *microphone_location(uint8_t location)
{
switch (location) {
case 0: return "laptop-top-panel";
@@ -74,21 +74,21 @@ static const char *microphone_location(u_int8_t location)
}
-static inline u_int8_t get_u8(u_int8_t *base, u_int32_t off)
+static inline uint8_t get_u8(uint8_t *base, uint32_t off)
{
return *(base + off);
}
-static inline int32_t get_s16le(u_int8_t *base, u_int32_t off)
+static inline int32_t get_s16le(uint8_t *base, uint32_t off)
{
- u_int32_t v = *(base + off + 0) |
+ uint32_t v = *(base + off + 0) |
(*(base + off + 1) << 8);
if (v & 0x8000)
return -((int32_t)0x10000 - (int32_t)v);
return v;
}
-static inline u_int32_t get_u32le(u_int8_t *base, u_int32_t off)
+static inline uint32_t get_u32le(uint8_t *base, uint32_t off)
{
return *(base + off + 0) |
(*(base + off + 1) << 8) |
@@ -138,10 +138,10 @@ static int nhlt_dmic_config(FILE *out, uint8_t *dmic, uint8_t mic)
return 0;
}
-static int nhlt_dmic_ep_to_json(FILE *out, uint8_t *ep, u_int32_t ep_size)
+static int nhlt_dmic_ep_to_json(FILE *out, uint8_t *ep, uint32_t ep_size)
{
- u_int32_t off, specific_cfg_size;
- u_int8_t config_type, array_type, mic, num_mics;
+ uint32_t off, specific_cfg_size;
+ uint8_t config_type, array_type, mic, num_mics;
int res;
off = NHLT_EP_HDR_SIZE;
@@ -182,15 +182,15 @@ oob:
return -EINVAL;
}
-static int nhlt_table_to_json(FILE *out, u_int8_t *nhlt, u_int32_t size)
+static int nhlt_table_to_json(FILE *out, uint8_t *nhlt, uint32_t size)
{
- u_int32_t _size, off, ep_size;
- u_int8_t sum = 0, ep, ep_count, link_type, dmics = 0;
+ uint32_t _size, off, ep_size;
+ uint8_t sum = 0, ep, ep_count, link_type, dmics = 0;
int res;
_size = get_u32le(nhlt, 4);
if (_size != size) {
- fprintf(stderr, "Table size mismatch (%08x != %08x)\n", _size, (u_int32_t)size);
+ fprintf(stderr, "Table size mismatch (%08x != %08x)\n", _size, (uint32_t)size);
return -EINVAL;
}
for (off = 0; off < size; off++)
@@ -232,7 +232,7 @@ oob:
static int nhlt_to_json(FILE *out, const char *nhlt_file)
{
struct stat st;
- u_int8_t *buf;
+ uint8_t *buf;
int _errno, fd, res;
size_t pos, size;
ssize_t ret;
--
2.35.3

View File

@ -0,0 +1,32 @@
From 5ae01fcf270864d379eefd81f1abc5b71907a72b Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Sat, 30 Sep 2023 10:09:46 +0100
Subject: [PATCH] Revert "nhlt-dmic-info.c: include sys/types.h"
This reverts commit 0925ad7f09b2dc77015784f9ac2f5e34dd0dd5c3.
This isn't necessary now that we use standard types (sys/types.h just
defines some compatibility typedefs).
Closes: https://github.com/alsa-project/alsa-utils/pull/234
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
nhlt/nhlt-dmic-info.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/nhlt/nhlt-dmic-info.c b/nhlt/nhlt-dmic-info.c
index eadf21a11bbc..f1b085742510 100644
--- a/nhlt/nhlt-dmic-info.c
+++ b/nhlt/nhlt-dmic-info.c
@@ -33,7 +33,6 @@
#include <fcntl.h>
#include <getopt.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <arpa/inet.h>
int debug = 0;
--
2.35.3

View File

@ -0,0 +1,451 @@
From 37447085c6fc975d191ecb508931a67bce79233d Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 17 Oct 2023 13:44:03 +0200
Subject: [PATCH] aplay: use stdint.h types instead u_int/u_short/u_char
Closes: https://github.com/alsa-project/alsa-utils/pull/234
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 92 ++++++++++++++++++++++++-------------------------
aplay/formats.h | 70 ++++++++++++++++++-------------------
2 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index f180d42b5516..9cf36dee2d9d 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -29,6 +29,7 @@
#define _GNU_SOURCE
#include "aconfig.h"
#include <stdio.h>
+#include <stdint.h>
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
@@ -50,7 +51,6 @@
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <endian.h>
#include "gettext.h"
#include "formats.h"
@@ -114,7 +114,7 @@ static int mmap_flag = 0;
static int interleaved = 1;
static int nonblock = 0;
static volatile sig_atomic_t in_aborting = 0;
-static u_char *audiobuf = NULL;
+static uint8_t *audiobuf = NULL;
static snd_pcm_uframes_t chunk_size = 0;
static unsigned period_time = 0;
static unsigned buffer_time = 0;
@@ -859,7 +859,7 @@ int main(int argc, char *argv[])
chunk_size = 1024;
hwparams = rhwparams;
- audiobuf = (u_char *)malloc(1024);
+ audiobuf = (uint8_t *)malloc(1024);
if (audiobuf == NULL) {
error(_("not enough memory"));
return 1;
@@ -970,7 +970,7 @@ static int test_vocfile(void *buffer)
* helper for test_wavefile
*/
-static size_t test_wavefile_read(int fd, u_char *buffer, size_t *size, size_t reqsize, int line)
+static size_t test_wavefile_read(int fd, uint8_t *buffer, size_t *size, size_t reqsize, int line)
{
if (*size >= reqsize)
return *size;
@@ -995,17 +995,17 @@ static size_t test_wavefile_read(int fd, u_char *buffer, size_t *size, size_t re
* == 0 if not
* Value returned is bytes to be discarded.
*/
-static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size)
+static ssize_t test_wavefile(int fd, uint8_t *_buffer, size_t size)
{
WaveHeader *h = (WaveHeader *)_buffer;
- u_char *buffer = NULL;
+ uint8_t *buffer = NULL;
size_t blimit = 0;
WaveFmtBody *f;
WaveChunkHeader *c;
- u_int type, len;
+ uint32_t type, len;
unsigned short format, channels;
int big_endian, native_format;
- u_char vbps = 0;
+ uint8_t vbps = 0;
if (size < sizeof(WaveHeader))
return -1;
@@ -1044,7 +1044,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size)
if (len < sizeof(WaveFmtBody)) {
error(_("unknown length of 'fmt ' chunk (read %u, should be %u at least)"),
- len, (u_int)sizeof(WaveFmtBody));
+ len, (uint32_t)sizeof(WaveFmtBody));
prg_exit(EXIT_FAILURE);
}
check_wavefile_space(buffer, len, blimit);
@@ -1055,7 +1055,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size)
WaveFmtExtensibleBody *fe = (WaveFmtExtensibleBody*)buffer;
if (len < sizeof(WaveFmtExtensibleBody)) {
error(_("unknown length of extensible 'fmt ' chunk (read %u, should be %u at least)"),
- len, (u_int)sizeof(WaveFmtExtensibleBody));
+ len, (unsigned int)sizeof(WaveFmtExtensibleBody));
prg_exit(EXIT_FAILURE);
}
if (memcmp(fe->guid_tag, WAV_GUID_TAG, 14) != 0) {
@@ -1167,7 +1167,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size)
size -= len;
while (1) {
- u_int type, len;
+ uint32_t type, len;
check_wavefile_space(buffer, sizeof(WaveChunkHeader), blimit);
test_wavefile_read(fd, buffer, &size, sizeof(WaveChunkHeader), __LINE__);
@@ -1809,7 +1809,7 @@ static void print_vu_meter(signed int *perc, signed int *maxperc)
}
/* peak handler */
-static void compute_max_peak(u_char *data, size_t samples)
+static void compute_max_peak(uint8_t *data, size_t samples)
{
signed int val, max, perc[2], max_peak[2];
static int run = 0;
@@ -2054,9 +2054,9 @@ static void do_test_position(void)
/*
*/
#ifdef CONFIG_SUPPORT_CHMAP
-static u_char *remap_data(u_char *data, size_t count)
+static uint8_t *remap_data(uint8_t *data, size_t count)
{
- static u_char *tmp, *src, *dst;
+ static uint8_t *tmp, *src, *dst;
static size_t tmp_size;
size_t sample_bytes = bits_per_sample / 8;
size_t step = bits_per_frame / 8;
@@ -2090,9 +2090,9 @@ static u_char *remap_data(u_char *data, size_t count)
return tmp;
}
-static u_char **remap_datav(u_char **data, size_t count ATTRIBUTE_UNUSED)
+static uint8_t **remap_datav(uint8_t **data, size_t count ATTRIBUTE_UNUSED)
{
- static u_char **tmp;
+ static uint8_t **tmp;
unsigned int ch;
if (!hw_map)
@@ -2118,7 +2118,7 @@ static u_char **remap_datav(u_char **data, size_t count ATTRIBUTE_UNUSED)
* write function
*/
-static ssize_t pcm_write(u_char *data, size_t count)
+static ssize_t pcm_write(uint8_t *data, size_t count)
{
ssize_t r;
ssize_t result = 0;
@@ -2157,7 +2157,7 @@ static ssize_t pcm_write(u_char *data, size_t count)
return result;
}
-static ssize_t pcm_writev(u_char **data, unsigned int channels, size_t count)
+static ssize_t pcm_writev(uint8_t **data, unsigned int channels, size_t count)
{
ssize_t r;
size_t result = 0;
@@ -2210,7 +2210,7 @@ static ssize_t pcm_writev(u_char **data, unsigned int channels, size_t count)
* read function
*/
-static ssize_t pcm_read(u_char *data, size_t rcount)
+static ssize_t pcm_read(uint8_t *data, size_t rcount)
{
ssize_t r;
size_t result = 0;
@@ -2252,7 +2252,7 @@ abort:
return result > rcount ? rcount : result;
}
-static ssize_t pcm_readv(u_char **data, unsigned int channels, size_t rcount)
+static ssize_t pcm_readv(uint8_t **data, unsigned int channels, size_t rcount)
{
ssize_t r;
size_t result = 0;
@@ -2304,7 +2304,7 @@ abort:
* ok, let's play a .voc file
*/
-static ssize_t voc_pcm_write(u_char *data, size_t count)
+static ssize_t voc_pcm_write(uint8_t *data, size_t count)
{
ssize_t result = count, r;
size_t size;
@@ -2329,9 +2329,9 @@ static ssize_t voc_pcm_write(u_char *data, size_t count)
static void voc_write_silence(unsigned x)
{
unsigned l;
- u_char *buf;
+ uint8_t *buf;
- buf = (u_char *) malloc(chunk_bytes);
+ buf = (uint8_t *) malloc(chunk_bytes);
if (buf == NULL) {
error(_("can't allocate buffer for silence"));
return; /* not fatal error */
@@ -2372,15 +2372,15 @@ static void voc_play(int fd, int ofs, char *name)
VocVoiceData *vd;
VocExtBlock *eb;
size_t nextblock, in_buffer;
- u_char *data, *buf;
+ uint8_t *data, *buf;
char was_extended = 0, output = 0;
- u_short *sp, repeat = 0;
+ uint16_t *sp, repeat = 0;
off_t filepos = 0;
#define COUNT(x) nextblock -= x; in_buffer -= x; data += x
#define COUNT1(x) in_buffer -= x; data += x
- data = buf = (u_char *)malloc(64 * 1024);
+ data = buf = (uint8_t *)malloc(64 * 1024);
buffer_pos = 0;
if (data == NULL) {
error(_("malloc error"));
@@ -2472,8 +2472,8 @@ static void voc_play(int fd, int ofs, char *name)
#endif
break;
case 3: /* a silence block, no data, only a count */
- sp = (u_short *) data;
- COUNT1(sizeof(u_short));
+ sp = (uint16_t *) data;
+ COUNT1(sizeof(uint16_t));
hwparams.rate = (int) (*data);
COUNT1(1);
hwparams.rate = 1000000 / (256 - hwparams.rate);
@@ -2488,8 +2488,8 @@ static void voc_play(int fd, int ofs, char *name)
voc_write_silence(*sp);
break;
case 4: /* a marker for syncronisation, no effect */
- sp = (u_short *) data;
- COUNT1(sizeof(u_short));
+ sp = (uint16_t *) data;
+ COUNT1(sizeof(uint16_t));
#if 0
d_printf("Marker %d\n", *sp);
#endif
@@ -2503,8 +2503,8 @@ static void voc_play(int fd, int ofs, char *name)
case 6: /* repeat marker, says repeatcount */
/* my specs don't say it: maybe this can be recursive, but
I don't think somebody use it */
- repeat = *(u_short *) data;
- COUNT1(sizeof(u_short));
+ repeat = *(uint16_t *) data;
+ COUNT1(sizeof(uint16_t));
#if 0
d_printf("Repeat loop %d times\n", repeat);
#endif
@@ -2649,14 +2649,14 @@ static void begin_voc(int fd, size_t cnt)
}
bt.type = 1;
cnt += sizeof(VocVoiceData); /* Channel_data block follows */
- bt.datalen = (u_char) (cnt & 0xFF);
- bt.datalen_m = (u_char) ((cnt & 0xFF00) >> 8);
- bt.datalen_h = (u_char) ((cnt & 0xFF0000) >> 16);
+ bt.datalen = (uint8_t) (cnt & 0xFF);
+ bt.datalen_m = (uint8_t) ((cnt & 0xFF00) >> 8);
+ bt.datalen_h = (uint8_t) ((cnt & 0xFF0000) >> 16);
if (xwrite(fd, &bt, sizeof(VocBlockType)) != sizeof(VocBlockType)) {
error(_("write error"));
prg_exit(EXIT_FAILURE);
}
- vd.tc = (u_char) (256 - (1000000 / hwparams.rate));
+ vd.tc = (uint8_t) (256 - (1000000 / hwparams.rate));
vd.pack = 0;
if (xwrite(fd, &vd, sizeof(VocVoiceData)) != sizeof(VocVoiceData)) {
error(_("write error"));
@@ -2671,8 +2671,8 @@ static void begin_wave(int fd, size_t cnt)
WaveFmtBody f;
WaveChunkHeader cf, cd;
int bits;
- u_int tmp;
- u_short tmp2;
+ uint32_t tmp;
+ uint16_t tmp2;
/* WAVE cannot handle greater than 32bit (signed?) int */
if (cnt == (size_t)-2)
@@ -2715,11 +2715,11 @@ static void begin_wave(int fd, size_t cnt)
#if 0
tmp2 = (samplesize == 8) ? 1 : 2;
f.byte_p_spl = LE_SHORT(tmp2);
- tmp = dsp_speed * hwparams.channels * (u_int) tmp2;
+ tmp = dsp_speed * hwparams.channels * (uint32_t) tmp2;
#else
tmp2 = hwparams.channels * snd_pcm_format_physical_width(hwparams.format) / 8;
f.byte_p_spl = LE_SHORT(tmp2);
- tmp = (u_int) tmp2 * hwparams.rate;
+ tmp = (uint32_t) tmp2 * hwparams.rate;
#endif
f.byte_p_sec = LE_INT(tmp);
f.bit_p_spl = LE_SHORT(bits);
@@ -2786,9 +2786,9 @@ static void end_voc(int fd)
cnt += sizeof(VocVoiceData); /* Channel_data block follows */
if (cnt > 0x00ffffff)
cnt = 0x00ffffff;
- bt.datalen = (u_char) (cnt & 0xFF);
- bt.datalen_m = (u_char) ((cnt & 0xFF00) >> 8);
- bt.datalen_h = (u_char) ((cnt & 0xFF0000) >> 16);
+ bt.datalen = (uint8_t) (cnt & 0xFF);
+ bt.datalen_m = (uint8_t) ((cnt & 0xFF00) >> 8);
+ bt.datalen_h = (uint8_t) ((cnt & 0xFF0000) >> 16);
if (lseek(fd, length_seek, SEEK_SET) == length_seek)
xwrite(fd, &bt, sizeof(VocBlockType));
}
@@ -2798,7 +2798,7 @@ static void end_wave(int fd)
WaveChunkHeader cd;
off_t length_seek;
off_t filelen;
- u_int rifflen;
+ uint32_t rifflen;
length_seek = sizeof(WaveHeader) +
sizeof(WaveChunkHeader) +
@@ -3339,7 +3339,7 @@ static void playbackv_go(int* fds, unsigned int channels, size_t loaded, off_t c
size_t vsize;
unsigned int channel;
- u_char *bufs[channels];
+ uint8_t *bufs[channels];
header(rtype, names[0]);
set_params();
@@ -3393,7 +3393,7 @@ static void capturev_go(int* fds, unsigned int channels, off_t count, int rtype,
ssize_t r;
unsigned int channel;
size_t vsize;
- u_char *bufs[channels];
+ uint8_t *bufs[channels];
header(rtype, names[0]);
set_params();
diff --git a/aplay/formats.h b/aplay/formats.h
index 093ab809382e..d82505e4626f 100644
--- a/aplay/formats.h
+++ b/aplay/formats.h
@@ -17,28 +17,28 @@
((u_long)(bp->datalen_h) << 16) )
typedef struct voc_header {
- u_char magic[20]; /* must be MAGIC_STRING */
- u_short headerlen; /* Headerlength, should be 0x1A */
- u_short version; /* VOC-file version */
- u_short coded_ver; /* 0x1233-version */
+ uint8_t magic[20]; /* must be MAGIC_STRING */
+ uint16_t headerlen; /* Headerlength, should be 0x1A */
+ uint16_t version; /* VOC-file version */
+ uint16_t coded_ver; /* 0x1233-version */
} VocHeader;
typedef struct voc_blocktype {
- u_char type;
- u_char datalen; /* low-byte */
- u_char datalen_m; /* medium-byte */
- u_char datalen_h; /* high-byte */
+ uint8_t type;
+ uint8_t datalen; /* low-byte */
+ uint8_t datalen_m; /* medium-byte */
+ uint8_t datalen_h; /* high-byte */
} VocBlockType;
typedef struct voc_voice_data {
- u_char tc;
- u_char pack;
+ uint8_t tc;
+ uint8_t pack;
} VocVoiceData;
typedef struct voc_ext_block {
- u_short tc;
- u_char pack;
- u_char mode;
+ uint16_t tc;
+ uint8_t pack;
+ uint8_t mode;
} VocExtBlock;
/* Definitions for Microsoft WAVE format */
@@ -85,32 +85,32 @@ typedef struct voc_ext_block {
it works on all WAVE-file I have
*/
typedef struct {
- u_int magic; /* 'RIFF' */
- u_int length; /* filelen */
- u_int type; /* 'WAVE' */
+ uint32_t magic; /* 'RIFF' */
+ uint32_t length; /* filelen */
+ uint32_t type; /* 'WAVE' */
} WaveHeader;
typedef struct {
- u_short format; /* see WAV_FMT_* */
- u_short channels;
- u_int sample_fq; /* frequence of sample */
- u_int byte_p_sec;
- u_short byte_p_spl; /* samplesize; 1 or 2 bytes */
- u_short bit_p_spl; /* 8, 12 or 16 bit */
+ uint16_t format; /* see WAV_FMT_* */
+ uint16_t channels;
+ uint32_t sample_fq; /* frequence of sample */
+ uint32_t byte_p_sec;
+ uint16_t byte_p_spl; /* samplesize; 1 or 2 bytes */
+ uint16_t bit_p_spl; /* 8, 12 or 16 bit */
} WaveFmtBody;
typedef struct {
WaveFmtBody format;
- u_short ext_size;
- u_short bit_p_spl;
- u_int channel_mask;
- u_short guid_format; /* WAV_FMT_* */
- u_char guid_tag[14]; /* WAV_GUID_TAG */
+ uint16_t ext_size;
+ uint16_t bit_p_spl;
+ uint32_t channel_mask;
+ uint16_t guid_format; /* WAV_FMT_* */
+ uint8_t guid_tag[14]; /* WAV_GUID_TAG */
} WaveFmtExtensibleBody;
typedef struct {
- u_int type; /* 'data' */
- u_int length; /* samplecount */
+ uint32_t type; /* 'data' */
+ uint32_t length; /* samplecount */
} WaveChunkHeader;
/* Definitions for Sparc .au header */
@@ -122,12 +122,12 @@ typedef struct {
#define AU_FMT_LIN16 3
typedef struct au_header {
- u_int magic; /* '.snd' */
- u_int hdr_size; /* size of header (min 24) */
- u_int data_size; /* size of data */
- u_int encoding; /* see to AU_FMT_XXXX */
- u_int sample_rate; /* sample rate */
- u_int channels; /* number of channels (voices) */
+ uint32_t magic; /* '.snd' */
+ uint32_t hdr_size; /* size of header (min 24) */
+ uint32_t data_size; /* size of data */
+ uint32_t encoding; /* see to AU_FMT_XXXX */
+ uint32_t sample_rate; /* sample rate */
+ uint32_t channels; /* number of channels (voices) */
} AuHeader;
#endif /* FORMATS */
--
2.35.3

View File

@ -0,0 +1,28 @@
From b5591747fd432d6289c9594a481982a77d357ed5 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Wed, 15 Nov 2023 15:02:31 +0100
Subject: [PATCH] alsa-restore.rules: use devnode instead number atribute
Fixes: https://github.com/alsa-project/alsa-utils/issues/244
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
alsactl/90-alsa-restore.rules.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/alsactl/90-alsa-restore.rules.in b/alsactl/90-alsa-restore.rules.in
index c0c1b232bb38..1a411c994870 100644
--- a/alsactl/90-alsa-restore.rules.in
+++ b/alsactl/90-alsa-restore.rules.in
@@ -2,7 +2,7 @@ ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", KERNELS!="card*", TEST==
GOTO="alsa_restore_end"
LABEL="alsa_restore_go"
-TEST!="@daemonswitch@", RUN+="@sbindir@/alsactl restore $attr{device/number}"
-TEST=="@daemonswitch@", RUN+="@sbindir@/alsactl nrestore $attr{device/number}"
+TEST!="@daemonswitch@", RUN+="@sbindir@/alsactl restore $devnode"
+TEST=="@daemonswitch@", RUN+="@sbindir@/alsactl nrestore $devnode"
LABEL="alsa_restore_end"
--
2.35.3

View File

@ -0,0 +1,43 @@
From 8f3d84ba19a45411f08bae13ee4dcd8329aa9438 Mon Sep 17 00:00:00 2001
From: Andy Ross <andyross@google.com>
Date: Thu, 7 Dec 2023 09:17:57 -0800
Subject: [PATCH] nhlt: Revert SSP_ANALOG device_type field
This partially reverts commit 3a47ef2487ed ("topology: nhlt: intel:
support more device types and directions"), which changed the default
device_type in the endpoint descriptor from zero to SSP_ANALOG.
This change breaks the Linux kernel NHLT parser (which AFAICT doesn't
recognize SSP_ANALOG at all), producing errors like:
[56458.583812] sof-audio-pci-intel-mtl 0000:00:1f.3: no matching blob for sample rate: 48000 sample width: 32 channels: 2
[56458.583833] sof-audio-pci-intel-mtl 0000:00:1f.3: failed to prepare widget dai-copier.SSP.SSP0-Codec.playback
[56458.583840] sof-audio-pci-intel-mtl 0000:00:1f.3: Failed to prepare connected widgets
[56458.583847] sof-audio-pci-intel-mtl 0000:00:1f.3: error: failed widget list set up for pcm 1 dir 0
[56458.583853] sof-audio-pci-intel-mtl 0000:00:1f.3: ASoC: error at snd_soc_pcm_component_hw_params on 0000:00:1f.3: -22
Revert for compatibility.
Fixes: https://github.com/alsa-project/alsa-utils/pull/248
Signed-off-by: Andy Ross <andyross@google.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
topology/nhlt/intel/ssp/ssp-process.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/topology/nhlt/intel/ssp/ssp-process.c b/topology/nhlt/intel/ssp/ssp-process.c
index 17b88d2b712b..d8fbba43f4c7 100644
--- a/topology/nhlt/intel/ssp/ssp-process.c
+++ b/topology/nhlt/intel/ssp/ssp-process.c
@@ -783,7 +783,7 @@ int ssp_get_params(struct intel_nhlt_params *nhlt, int dai_index, uint32_t *virt
if (ssp->ssp_prm[dai_index].quirks & SSP_INTEL_QUIRK_BT_SIDEBAND)
*device_type = NHLT_DEVICE_TYPE_SSP_BT_SIDEBAND;
else
- *device_type = NHLT_DEVICE_TYPE_SSP_ANALOG;
+ *device_type = 0;
if (ssp->ssp_prm[dai_index].quirks & SSP_INTEL_QUIRK_RENDER_FEEDBACK) {
if (*direction == NHLT_ENDPOINT_DIRECTION_RENDER)
*direction = NHLT_ENDPOINT_DIRECTION_RENDER_WITH_LOOPBACK;
--
2.35.3

View File

@ -0,0 +1,31 @@
From 004d085c675c56f866f008dbf712ee7503de5b27 Mon Sep 17 00:00:00 2001
From: Mingjie Shen <shen497@purdue.edu>
Date: Wed, 6 Dec 2023 16:49:26 -0500
Subject: [PATCH] alsactl: fix potential buffer overwrite
The 'call to sprintf' operation on line 413 requires 21 bytes
but the destination is only 16 bytes.
Fixes: https://github.com/alsa-project/alsa-utils/pull/247
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
alsactl/alsactl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c
index a854c0bdc16f..8ad991a0f36b 100644
--- a/alsactl/alsactl.c
+++ b/alsactl/alsactl.c
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
char *cfgfile = SYS_ASOUNDRC;
char *initfile = DATADIR "/init/00main";
char *pidfile = SYS_PIDFILE;
- char *cardname, ncardname[16];
+ char *cardname, ncardname[21];
char *cmd;
char *const *extra_args;
const char *const *tmp;
--
2.35.3

View File

@ -0,0 +1,70 @@
From 4ce6a0a4af518700c3e44257af5f44ff24d58fc9 Mon Sep 17 00:00:00 2001
From: Mingjie Shen <shen497@purdue.edu>
Date: Wed, 6 Dec 2023 16:09:58 -0500
Subject: [PATCH] aplay: fix buffer overflow and tainted format string
Prior this commit, memcpy from names[0] to format[] will overwrite if
strlen(names[0]) is greater than 1024. Also, the length of malloc()ed
names[channel] is insufficient, leading to another buffer overwriting
when calling sprintf(). Moreover, the format string of sprintf()
can be controlled by user input. An attacker can exploit this weakness
to crash the program, disclose information or even execute arbitrary
code.
Fix by allocating enough space for arrays and using constant expressions
as the format strings.
Fixes: https://github.com/alsa-project/alsa-utils/pull/246/
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index 9cf36dee2d9d..f1c27b6c4929 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -3436,14 +3436,14 @@ static void playbackv(char **names, unsigned int count)
if (count == 1 && channels > 1) {
size_t len = strlen(names[0]);
- char format[1024];
- memcpy(format, names[0], len);
- strcpy(format + len, ".%d");
- len += 4;
+ char buf[len + 1];
+ strcpy(buf, names[0]);
+ /* 1 for "." + 3 for channel (<= 256) + 1 for null terminator */
+ len += 5;
names = malloc(sizeof(*names) * channels);
for (channel = 0; channel < channels; ++channel) {
names[channel] = malloc(len);
- sprintf(names[channel], format, channel);
+ snprintf(names[channel], len, "%s.%d", buf, channel);
}
alloced = 1;
} else if (count != channels) {
@@ -3489,14 +3489,14 @@ static void capturev(char **names, unsigned int count)
if (count == 1) {
size_t len = strlen(names[0]);
- char format[1024];
- memcpy(format, names[0], len);
- strcpy(format + len, ".%d");
- len += 4;
+ char buf[len + 1];
+ strcpy(buf, names[0]);
+ /* 1 for "." + 3 for channel (<= 256) + 1 for null terminator */
+ len += 5;
names = malloc(sizeof(*names) * channels);
for (channel = 0; channel < channels; ++channel) {
names[channel] = malloc(len);
- sprintf(names[channel], format, channel);
+ snprintf(names[channel], len, "%s.%d", buf, channel);
}
alloced = 1;
} else if (count != channels) {
--
2.35.3

View File

@ -0,0 +1,102 @@
From edff9652c050935ad7a0131b5585b4dad5e42296 Mon Sep 17 00:00:00 2001
From: Tianyi Liu <i.pear@outlook.com>
Date: Tue, 21 Nov 2023 23:19:35 +0800
Subject: [PATCH] misc: fix incorrect usages of `strerror`
`strerror` takes the `errno` directly as its argument,
negating it will result in an "Unknown error".
This fixes such usages across multiple modules.
Fixes: https://github.com/alsa-project/alsa-utils/pull/245
Signed-off-by: Tianyi Liu <i.pear@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
alsaucm/usecase.c | 2 +-
nhlt/nhlt-dmic-info.c | 2 +-
topology/topology.c | 12 ++++++------
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/alsaucm/usecase.c b/alsaucm/usecase.c
index a5c815591dca..0aea84c6cd1e 100644
--- a/alsaucm/usecase.c
+++ b/alsaucm/usecase.c
@@ -510,7 +510,7 @@ int main(int argc, char *argv[])
in = fopen(context->batch, "r");
if (in == NULL) {
fprintf(stderr, "%s: error failed to open file '%s': %s\n",
- command, context->batch, strerror(-errno));
+ command, context->batch, strerror(errno));
my_exit(context, EXIT_FAILURE);
}
}
diff --git a/nhlt/nhlt-dmic-info.c b/nhlt/nhlt-dmic-info.c
index f1b085742510..f08dc85d02eb 100644
--- a/nhlt/nhlt-dmic-info.c
+++ b/nhlt/nhlt-dmic-info.c
@@ -404,7 +404,7 @@ int main(int argc, char *argv[])
output = fopen(output_file, "w+");
if (output == NULL) {
fprintf(stderr, "Unable to create output file \"%s\": %s\n",
- output_file, strerror(-errno));
+ output_file, strerror(errno));
res = EXIT_FAILURE;
goto out;
}
diff --git a/topology/topology.c b/topology/topology.c
index 98b000aa5031..9752f8889367 100644
--- a/topology/topology.c
+++ b/topology/topology.c
@@ -96,7 +96,7 @@ static int load(const char *source_file, void **dst, size_t *dst_size)
fd = open(source_file, O_RDONLY);
if (fd < 0) {
fprintf(stderr, _("Unable to open input file '%s': %s\n"),
- source_file, strerror(-errno));
+ source_file, strerror(errno));
return 1;
}
}
@@ -120,7 +120,7 @@ static int load(const char *source_file, void **dst, size_t *dst_size)
buf = buf2;
}
if (r < 0) {
- fprintf(stderr, _("Read error: %s\n"), strerror(-errno));
+ fprintf(stderr, _("Read error: %s\n"), strerror(errno));
goto _err;
}
@@ -177,7 +177,7 @@ static int save(const char *output_file, void *buf, size_t size)
fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0) {
fprintf(stderr, _("Unable to open output file '%s': %s\n"),
- fname, strerror(-errno));
+ fname, strerror(errno));
return 1;
}
}
@@ -194,11 +194,11 @@ static int save(const char *output_file, void *buf, size_t size)
}
if (r < 0) {
- fprintf(stderr, _("Write error: %s\n"), strerror(-errno));
+ fprintf(stderr, _("Write error: %s\n"), strerror(errno));
if (fd != fileno(stdout)) {
if (fname && remove(fname))
fprintf(stderr, _("Unable to remove file %s: %s\n"),
- fname, strerror(-errno));
+ fname, strerror(errno));
close(fd);
}
return 1;
@@ -209,7 +209,7 @@ static int save(const char *output_file, void *buf, size_t size)
if (fname && rename(fname, output_file)) {
fprintf(stderr, _("Unable to rename file '%s' to '%s': %s\n"),
- fname, output_file, strerror(-errno));
+ fname, output_file, strerror(errno));
return 1;
}
--
2.35.3

View File

@ -0,0 +1,97 @@
From d55cd9fcd9e96e96b27bea778c70dd4459e6d2a3 Mon Sep 17 00:00:00 2001
From: Cezary Rojewski <cezary.rojewski@intel.com>
Date: Fri, 4 Aug 2023 10:26:50 +0200
Subject: [PATCH] aplay: Add option for specifying subformat
Make subformat first-class citizen by allowing users to specify it just
like it is the case for the format. Default to SND_PCM_SUBFORMAT_STD so
they are no surprises.
Closes: https://github.com/alsa-project/alsa-utils/pull/228
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index f1c27b6c4929..03443df52d33 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -101,6 +101,7 @@ static char *command;
static snd_pcm_t *handle;
static struct {
snd_pcm_format_t format;
+ snd_pcm_subformat_t subformat;
unsigned int channels;
unsigned int rate;
} hwparams, rhwparams;
@@ -216,6 +217,7 @@ _("Usage: %s [OPTION]... [FILE]...\n"
"-t, --file-type TYPE file type (voc, wav, raw or au)\n"
"-c, --channels=# channels\n"
"-f, --format=FORMAT sample format (case insensitive)\n"
+" --subformat=SUBFORMAT sample subformat (case insensitive)\n"
"-r, --rate=# sample rate\n"
"-d, --duration=# interrupt after # seconds\n"
"-s, --samples=# interrupt after # samples per channel\n"
@@ -434,6 +436,7 @@ enum {
OPT_USE_STRFTIME,
OPT_DUMP_HWPARAMS,
OPT_FATAL_ERRORS,
+ OPT_SUBFORMAT,
};
/*
@@ -491,6 +494,7 @@ int main(int argc, char *argv[])
{"file-type", 1, 0, 't'},
{"channels", 1, 0, 'c'},
{"format", 1, 0, 'f'},
+ {"subformat", 1, 0, OPT_SUBFORMAT},
{"rate", 1, 0, 'r'},
{"duration", 1, 0 ,'d'},
{"samples", 1, 0, 's'},
@@ -566,6 +570,7 @@ int main(int argc, char *argv[])
chunk_size = -1;
rhwparams.format = DEFAULT_FORMAT;
+ rhwparams.subformat = SND_PCM_SUBFORMAT_STD;
rhwparams.rate = DEFAULT_SPEED;
rhwparams.channels = 1;
@@ -635,6 +640,13 @@ int main(int argc, char *argv[])
}
}
break;
+ case OPT_SUBFORMAT:
+ rhwparams.subformat = snd_pcm_subformat_value(optarg);
+ if (rhwparams.subformat == SND_PCM_SUBFORMAT_UNKNOWN) {
+ error(_("wrong extended subformat '%s'"), optarg);
+ prg_exit(EXIT_FAILURE);
+ }
+ break;
case 'r':
tmp = parse_long(optarg, &err);
if (err < 0) {
@@ -1372,6 +1384,11 @@ static void set_params(void)
show_available_sample_formats(params);
prg_exit(EXIT_FAILURE);
}
+ err = snd_pcm_hw_params_set_subformat(handle, params, hwparams.subformat);
+ if (err < 0) {
+ error(_("Sample subformat not available"));
+ prg_exit(EXIT_FAILURE);
+ }
err = snd_pcm_hw_params_set_channels(handle, params, hwparams.channels);
if (err < 0) {
error(_("Channels count non available"));
@@ -2404,6 +2421,7 @@ static void voc_play(int fd, int ofs, char *name)
}
}
hwparams.format = DEFAULT_FORMAT;
+ hwparams.subformat = SND_PCM_SUBFORMAT_STD;
hwparams.channels = 1;
hwparams.rate = DEFAULT_SPEED;
set_params();
--
2.35.3

View File

@ -0,0 +1,30 @@
From 8e6351f19d803e969c5d2fc874033f3cf68b89c4 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 12 Dec 2023 13:47:03 +0100
Subject: [PATCH] aplay: allow to compile with older alsa-lib (subformat)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index 03443df52d33..fc4bac697226 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -641,8 +641,12 @@ int main(int argc, char *argv[])
}
break;
case OPT_SUBFORMAT:
+#if SND_LIB_VER(1, 2, 10) < SND_LIB_VERSION
rhwparams.subformat = snd_pcm_subformat_value(optarg);
if (rhwparams.subformat == SND_PCM_SUBFORMAT_UNKNOWN) {
+#else
+ if (strcasecmp(optarg, "std") != 0 && strcasecmp(optarg, "standard") != 0) {
+#endif
error(_("wrong extended subformat '%s'"), optarg);
prg_exit(EXIT_FAILURE);
}
--
2.35.3

View File

@ -0,0 +1,50 @@
From 6e9be2a3f356d79da3b71c9244d4c809baf38e52 Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Fri, 27 Oct 2023 15:05:06 -0500
Subject: [PATCH] aplay: log pcm status before reporting a fatal error
When the --fatal-errors happen, nothing is provided to the user even
when the '-v' verbose option is specified. This patch adds the fatal
error exit after dumping the logs. No functionality change, just
better information on what just happened.
Closes: https://github.com/alsa-project/alsa-utils/pull/242
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index fc4bac697226..ed58a1ec8c7f 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -1677,12 +1677,6 @@ static void xrun(void)
prg_exit(EXIT_FAILURE);
}
if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
- if (fatal_errors) {
- error(_("fatal %s: %s"),
- stream == SND_PCM_STREAM_PLAYBACK ? _("underrun") : _("overrun"),
- snd_strerror(res));
- prg_exit(EXIT_FAILURE);
- }
if (monotonic) {
#ifdef HAVE_CLOCK_GETTIME
struct timespec now, diff, tstamp;
@@ -1708,6 +1702,12 @@ static void xrun(void)
fprintf(stderr, _("Status:\n"));
snd_pcm_status_dump(status, log);
}
+ if (fatal_errors) {
+ error(_("fatal %s: %s"),
+ stream == SND_PCM_STREAM_PLAYBACK ? _("underrun") : _("overrun"),
+ snd_strerror(res));
+ prg_exit(EXIT_FAILURE);
+ }
if ((res = snd_pcm_prepare(handle))<0) {
error(_("xrun: prepare error: %s"), snd_strerror(res));
prg_exit(EXIT_FAILURE);
--
2.35.3

View File

@ -0,0 +1,65 @@
From 35f45c50eeb779724f882c4e98a279934e1e3140 Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Fri, 27 Oct 2023 15:09:56 -0500
Subject: [PATCH] aplay: enable timestamps by default
When the '-v' or '--test-position' options are used, the 'tstamp' is
shown as zero. Unconditionally enable the timestamps and choose the
timestamp time based on the 'monotonic' variable.
Example log:
Status(R/W) (standalone avail=36 delay=924):
state : RUNNING
trigger_time: 2045.504937
tstamp : 2190.754602
delay : 924
avail : 36
avail_max : 444
Status(R/W) (standalone avail=44 delay=912):
state : RUNNING
trigger_time: 2045.504937
tstamp : 2190.754852
delay : 912
avail : 48
avail_max : 48
underrun!!! (at least 471.161 ms long)
Status:
state : XRUN
trigger_time: 2190.786234
tstamp : 2191.257392
delay : 0
avail : 1412
avail_max : 1412
aplay: xrun:1690: fatal underrun: Success
Closes: https://github.com/alsa-project/alsa-utils/pull/242
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index ed58a1ec8c7f..2a75de72523d 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -1494,6 +1494,15 @@ static void set_params(void)
err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
assert(err >= 0);
+ err = snd_pcm_sw_params_set_tstamp_mode(handle, swparams, SND_PCM_TSTAMP_ENABLE);
+ assert(err >= 0);
+
+ if (monotonic)
+ err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, SND_PCM_TSTAMP_TYPE_MONOTONIC);
+ else
+ err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY);
+ assert(err >= 0);
+
if (snd_pcm_sw_params(handle, swparams) < 0) {
error(_("unable to install sw params:"));
snd_pcm_sw_params_dump(swparams, log);
--
2.35.3

View File

@ -0,0 +1,43 @@
From 827905c002dad40a7821a55b570aeaf55b4f1614 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 12 Dec 2023 15:07:06 +0100
Subject: [PATCH] aplay: status dumps are called only in verbose mode
Do not enable timestamps for the normal operation.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index 2a75de72523d..6c5a07eff7d4 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -1494,14 +1494,16 @@ static void set_params(void)
err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
assert(err >= 0);
- err = snd_pcm_sw_params_set_tstamp_mode(handle, swparams, SND_PCM_TSTAMP_ENABLE);
- assert(err >= 0);
+ if (verbose) {
+ err = snd_pcm_sw_params_set_tstamp_mode(handle, swparams, SND_PCM_TSTAMP_ENABLE);
+ assert(err >= 0);
- if (monotonic)
- err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, SND_PCM_TSTAMP_TYPE_MONOTONIC);
- else
- err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY);
- assert(err >= 0);
+ if (monotonic)
+ err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, SND_PCM_TSTAMP_TYPE_MONOTONIC);
+ else
+ err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY);
+ assert(err >= 0);
+ }
if (snd_pcm_sw_params(handle, swparams) < 0) {
error(_("unable to install sw params:"));
--
2.35.3

View File

@ -0,0 +1,35 @@
From 4cb3e3a7b5b2347e87747a5544c1f4db62a7be53 Mon Sep 17 00:00:00 2001
From: "John K. Luebs" <john@luebs.org>
Date: Sun, 7 Jan 2024 13:33:33 -0600
Subject: [PATCH] aplaymidi: Set event completely for tempo event
After UMP support was added in b399fb8 ev.type setting was inadvertently
dropped in the code path handling tempo meta event.
This is causing tempo meta events to not be handled at all.
Moreover, snd_seq_ev_set_fixed is also missing so MIDI files with
variable events such as SYSEX before the tempo meta event usually are
causing a segfault.
Fixes: b399fb85a919 ("aplaymidi: Add UMP support")
Closes: https://github.com/alsa-project/alsa-utils/issues/241
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
seq/aplaymidi/aplaymidi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/seq/aplaymidi/aplaymidi.c b/seq/aplaymidi/aplaymidi.c
index a7293d31fb31..66038e278d4a 100644
--- a/seq/aplaymidi/aplaymidi.c
+++ b/seq/aplaymidi/aplaymidi.c
@@ -819,6 +819,8 @@ static void play_midi(void)
ev.time.tick = event->tick;
ev.dest = ports[event->port];
if (event->type == SND_SEQ_EVENT_TEMPO) {
+ snd_seq_ev_set_fixed(&ev);
+ ev.type = event->type;
ev.dest.client = SND_SEQ_CLIENT_SYSTEM;
ev.dest.port = SND_SEQ_PORT_SYSTEM_TIMER;
ev.data.queue.queue = queue;
--
2.35.3

View File

@ -1,3 +1,29 @@
-------------------------------------------------------------------
Mon Jan 8 09:12:41 UTC 2024 - Takashi Iwai <tiwai@suse.com>
- Backport upstream fixes:
buffer overflow fixes in aplay, segfault in aplaymidi, etc:
0008-topology-include-locale.h.patch
0009-nhlt-dmic-info.c-include-sys-types.h.patch
0010-topology-pre-processor-Add-support-for-enum-controls.patch
0011-configure.ac-fix-UMP-support-detection.patch
0012-bat-really-skip-analysis-of-the-first-period-and-upd.patch
0013-topology-add-include-for-ENABLE_NLS-on-musl.patch
0014-nhlt-use-stdint.h-types.patch
0015-Revert-nhlt-dmic-info.c-include-sys-types.h.patch
0016-aplay-use-stdint.h-types-instead-u_int-u_short-u_cha.patch
0017-alsa-restore.rules-use-devnode-instead-number-atribu.patch
0018-nhlt-Revert-SSP_ANALOG-device_type-field.patch
0019-alsactl-fix-potential-buffer-overwrite.patch
0020-aplay-fix-buffer-overflow-and-tainted-format-string.patch
0021-misc-fix-incorrect-usages-of-strerror.patch
0022-aplay-Add-option-for-specifying-subformat.patch
0023-aplay-allow-to-compile-with-older-alsa-lib-subformat.patch
0024-aplay-log-pcm-status-before-reporting-a-fatal-error.patch
0025-aplay-enable-timestamps-by-default.patch
0026-aplay-status-dumps-are-called-only-in-verbose-mode.patch
0027-aplaymidi-Set-event-completely-for-tempo-event.patch
-------------------------------------------------------------------
Mon Sep 4 12:38:04 UTC 2023 - Takashi Iwai <tiwai@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package alsa-utils
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -16,7 +16,7 @@
#
%define do_autoreconf 0
%define do_autoreconf 1
%define _udevdir %(pkg-config --variable=udevdir udev)
%ifarch %ix86 x86_64 %arm aarch64 ppc64le riscv64
%define enable_topology 1
@ -46,6 +46,26 @@ Patch4: 0004-bat-use-ATTRIBUTE_UNUSED-instead-remove-argument-nam.patch
Patch5: 0005-seq-use-ATTRIBUTE_UNUSED-instead-remove-argument-nam.patch
Patch6: 0006-alsaucm-use-ATTRIBUTE_UNUSED-instead-remove-argument.patch
Patch7: 0007-topology-use-ATTRIBUTE_UNUSED-instead-remove-argumen.patch
Patch8: 0008-topology-include-locale.h.patch
Patch9: 0009-nhlt-dmic-info.c-include-sys-types.h.patch
Patch10: 0010-topology-pre-processor-Add-support-for-enum-controls.patch
Patch11: 0011-configure.ac-fix-UMP-support-detection.patch
Patch12: 0012-bat-really-skip-analysis-of-the-first-period-and-upd.patch
Patch13: 0013-topology-add-include-for-ENABLE_NLS-on-musl.patch
Patch14: 0014-nhlt-use-stdint.h-types.patch
Patch15: 0015-Revert-nhlt-dmic-info.c-include-sys-types.h.patch
Patch16: 0016-aplay-use-stdint.h-types-instead-u_int-u_short-u_cha.patch
Patch17: 0017-alsa-restore.rules-use-devnode-instead-number-atribu.patch
Patch18: 0018-nhlt-Revert-SSP_ANALOG-device_type-field.patch
Patch19: 0019-alsactl-fix-potential-buffer-overwrite.patch
Patch20: 0020-aplay-fix-buffer-overflow-and-tainted-format-string.patch
Patch21: 0021-misc-fix-incorrect-usages-of-strerror.patch
Patch22: 0022-aplay-Add-option-for-specifying-subformat.patch
Patch23: 0023-aplay-allow-to-compile-with-older-alsa-lib-subformat.patch
Patch24: 0024-aplay-log-pcm-status-before-reporting-a-fatal-error.patch
Patch25: 0025-aplay-enable-timestamps-by-default.patch
Patch26: 0026-aplay-status-dumps-are-called-only-in-verbose-mode.patch
Patch27: 0027-aplaymidi-Set-event-completely-for-tempo-event.patch
Patch100: alsa-info-no-update-for-distro-script.patch
Patch101: alsa-utils-configure-version-revert.patch
BuildRequires: alsa-devel
@ -97,6 +117,26 @@ and test audio before and after PM state changes.
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch100 -p1
%if 0%{?do_autoreconf}
%patch101 -p1