- Backport upstream fixes: 0001-ucm-substitution-remove-duplicate-allow_empty-assign.patch 0002-ucm-fix-parse_get_safe_name-safe-name-must-be-checke.patch 0003-ucm-substitute-the-merged-tree-completely.patch 0004-ctl-improve-documentation-for-identifier-of-control-.patch 0005-pcm-dmix-make-lockless-operation-optional.patch 0006-pcm-dmix-Fix-semaphore-usage-with-lockless-operation.patch 0007-pcm-iec958-implement-HDMI-HBR-audio-formatting.patch 0008-pcm-iec958-set-channel-status-bits-according-to-rate.patch 0009-conf-pcm-USB-Added-S-PDIF-fix-for-Asus-Xonar-SE.patch 0010-control-ctlparse-fix-enum-values-in-or.patch 0011-conf-USB-Audio-Disable-IEC958-on-Lenovo-ThinkStation.patch 0012-pcm-dmix-fix-access-to-sum-buffer-in-non-interleaved.patch 0014-control-Add-documentation-for-snd_ctl_elem_list_.patch 0015-conf-quote-also-strings-with-and-characters-in-strin.patch 0016-topology-decode-Fix-channel-map-memory-allocation.patch 0017-topology-decode-Fix-infinite-loop-in-decoding-enum-c.patch 0018-topology-decode-Remove-decoding-values-for-enum-cont.patch 0019-topology-decode-Add-enum-control-texts-as-separate-e.patch 0020-topology-decode-Fix-printing-texts-section.patch 0021-topology-decode-Change-declaration-of-enum-decoding-.patch 0022-topology-decode-Fix-decoding-PCM-formats-and-rates.patch 0023-topology-decode-Print-sig_bits-field-in-PCM-capabili.patch 0024-topology-decode-Add-DAI-name-printing.patch 0025-topology-Make-buffer-for-saving-dynamic-size.patch 0026-topology-return-correct-value-in-tplg_save_printf.patch 0027-topology-fix-some-gcc10-warnings-labs-signess.patch 0028-topology-fix-sort_config.patch 0029-topology-fix-the-unaligned-access.patch 0030-topology-improve-the-printf-buffer-management.patch OBS-URL: https://build.opensuse.org/request/show/836375 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=281
95 lines
2.3 KiB
Diff
95 lines
2.3 KiB
Diff
From d04e72c9a593015952e4858b92ab3f9d821560d9 Mon Sep 17 00:00:00 2001
|
|
From: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
|
|
Date: Mon, 31 Aug 2020 11:09:03 +0200
|
|
Subject: [PATCH 25/32] topology: Make buffer for saving dynamic size
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Some fields can exceed size limit, e.g. private data has no size
|
|
restriction. Therefore it needs to be dynamically increased.
|
|
|
|
Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
|
|
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
|
|
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
|
|
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
|
|
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
|
---
|
|
src/topology/save.c | 34 +++++++++++++++++++++++++++++-----
|
|
1 file changed, 29 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/topology/save.c b/src/topology/save.c
|
|
index 4ecf86c3ade4..9c74735aea36 100644
|
|
--- a/src/topology/save.c
|
|
+++ b/src/topology/save.c
|
|
@@ -19,22 +19,43 @@
|
|
#include "tplg_local.h"
|
|
|
|
#define SAVE_ALLOC_SHIFT (13) /* 8192 bytes */
|
|
+#define PRINT_BUF_SIZE (1024)
|
|
+#define PRINT_BUF_SIZE_MAX (1024 * 1024)
|
|
|
|
int tplg_save_printf(char **dst, const char *pfx, const char *fmt, ...)
|
|
{
|
|
va_list va;
|
|
- char buf[1024], *s;
|
|
+ char *buf, *s;
|
|
size_t n, l, t, pl;
|
|
+ int ret = 0;
|
|
+
|
|
+ buf = malloc(PRINT_BUF_SIZE);
|
|
+ if (!buf)
|
|
+ return -ENOMEM;
|
|
|
|
if (pfx == NULL)
|
|
pfx = "";
|
|
|
|
va_start(va, fmt);
|
|
- n = vsnprintf(buf, sizeof(buf), fmt, va);
|
|
+ n = vsnprintf(buf, PRINT_BUF_SIZE, fmt, va);
|
|
va_end(va);
|
|
|
|
- if (n >= sizeof(buf))
|
|
- return -EOVERFLOW;
|
|
+ if (n >= PRINT_BUF_SIZE_MAX) {
|
|
+ ret = -EOVERFLOW;
|
|
+ goto end;
|
|
+ }
|
|
+
|
|
+ if (n >= PRINT_BUF_SIZE) {
|
|
+ char *tmp = realloc(buf, n + 1);
|
|
+ if (!tmp) {
|
|
+ ret = -ENOMEM;
|
|
+ goto end;
|
|
+ }
|
|
+ buf = tmp;
|
|
+ va_start(va, fmt);
|
|
+ n = vsnprintf(buf, n + 1, fmt, va);
|
|
+ va_end(va);
|
|
+ }
|
|
|
|
pl = strlen(pfx);
|
|
l = *dst ? strlen(*dst) : 0;
|
|
@@ -47,7 +68,8 @@ int tplg_save_printf(char **dst, const char *pfx, const char *fmt, ...)
|
|
if (s == NULL) {
|
|
free(*dst);
|
|
*dst = NULL;
|
|
- return -ENOMEM;
|
|
+ ret = -ENOMEM;
|
|
+ goto end;
|
|
}
|
|
} else {
|
|
s = *dst;
|
|
@@ -57,6 +79,8 @@ int tplg_save_printf(char **dst, const char *pfx, const char *fmt, ...)
|
|
strcpy(s + l, pfx);
|
|
strcpy(s + l + pl, buf);
|
|
*dst = s;
|
|
+end:
|
|
+ free(buf);
|
|
return 0;
|
|
}
|
|
|
|
--
|
|
2.16.4
|
|
|