Antonio Larrosa
0978c7828b
- Add upstream patches to fix glfo#pipewire/pipewire#2214 and to handle better non-null terminated strings: * 0001-alsa-monitor-handle-snd_aloop-devices-better.patch * 0001-spa-json-make-sure-we-only-add-encoded-string-data.patch * 0001-m-lua-scripting-ignore-string-integer-table-keys-when-constructing-a-JSON-Array-Object.patch OBS-URL: https://build.opensuse.org/request/show/1057777 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/wireplumber?expand=0&rev=55
76 lines
2.5 KiB
Diff
76 lines
2.5 KiB
Diff
From 10f85549a42cd33daaa7a0c4eb1329c5f8067b7d Mon Sep 17 00:00:00 2001
|
|
From: Julian Bouzas <julian.bouzas@collabora.com>
|
|
Date: Wed, 4 Jan 2023 10:07:36 -0500
|
|
Subject: [PATCH] spa-json: make sure we only add encoded string data
|
|
|
|
The spa_json_encode_string() API does not add a null terminator character. We
|
|
need to use the return value to know the size of the encoded string when adding
|
|
it to the builder.
|
|
---
|
|
lib/wp/spa-json.c | 24 +++++++++++++++++-------
|
|
1 file changed, 17 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/lib/wp/spa-json.c b/lib/wp/spa-json.c
|
|
index 1649f64b..6c797cf9 100644
|
|
--- a/lib/wp/spa-json.c
|
|
+++ b/lib/wp/spa-json.c
|
|
@@ -391,9 +391,8 @@ wp_spa_json_new_string (const gchar *value)
|
|
{
|
|
size_t size = (strlen (value) * 4) + 2;
|
|
gchar dst[size];
|
|
- spa_json_encode_string (dst, sizeof(dst), value);
|
|
- return wp_spa_json_new_from_builder (
|
|
- wp_spa_json_builder_new_formatted ("%s", dst));
|
|
+ gint enc_size = spa_json_encode_string (dst, sizeof(dst), value);
|
|
+ return wp_spa_json_new_from_builder (wp_spa_json_builder_new (dst, enc_size));
|
|
}
|
|
|
|
/* Args is not a pointer in some architectures, so this needs to be a macro to
|
|
@@ -970,6 +969,14 @@ builder_add_formatted (WpSpaJsonBuilder *self, const gchar *fmt, ...)
|
|
self->size += s;
|
|
}
|
|
|
|
+static void
|
|
+builder_add (WpSpaJsonBuilder *self, const gchar *data, size_t size)
|
|
+{
|
|
+ g_return_if_fail (self->max_size - self->size >= size + 1);
|
|
+ snprintf (self->data + self->size, size + 1, "%s", data);
|
|
+ self->size += size;
|
|
+}
|
|
+
|
|
static void
|
|
builder_add_json (WpSpaJsonBuilder *self, WpSpaJson *json)
|
|
{
|
|
@@ -990,10 +997,12 @@ wp_spa_json_builder_add_property (WpSpaJsonBuilder *self, const gchar *key)
|
|
{
|
|
size_t size = (strlen (key) * 4) + 3;
|
|
gchar dst[size];
|
|
+ gint enc_size;
|
|
ensure_separator (self, TRUE);
|
|
ensure_allocated_max_size (self, size);
|
|
- spa_json_encode_string (dst, sizeof(dst), key);
|
|
- builder_add_formatted (self, "%s:", dst);
|
|
+ enc_size = spa_json_encode_string (dst, sizeof(dst), key);
|
|
+ builder_add (self, dst, enc_size);
|
|
+ builder_add (self, ":", 1);
|
|
}
|
|
|
|
/*!
|
|
@@ -1067,10 +1076,11 @@ wp_spa_json_builder_add_string (WpSpaJsonBuilder *self, const gchar *value)
|
|
{
|
|
size_t size = (strlen (value) * 4) + 2;
|
|
gchar dst[size];
|
|
+ gint enc_size;
|
|
ensure_separator (self, FALSE);
|
|
ensure_allocated_max_size (self, size);
|
|
- spa_json_encode_string (dst, sizeof(dst), value);
|
|
- builder_add_formatted (self, "%s", dst);
|
|
+ enc_size = spa_json_encode_string (dst, sizeof(dst), value);
|
|
+ builder_add (self, dst, enc_size);
|
|
}
|
|
|
|
/*!
|
|
--
|
|
GitLab
|
|
|