From 298a537d5f6783e55d87e40011ee3fd3b22b72f9 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 17 Aug 2023 01:39:01 +0000 Subject: [PATCH] gvariant: Zero-initialise various GVariantSerialised objects The following few commits will add a couple of new fields to `GVariantSerialised`, and they should be zero-filled by default. Try and pre-empt that a bit by zero-filling `GVariantSerialised` by default in a few places. Signed-off-by: Philip Withnall Helps: #2121 CVE: CVE-2023-32665 Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/298a537d5f6783e55d87e40011ee3fd3b22b72f9] Signed-off-by: Soumya Sambu --- glib/gvariant.c | 2 +- glib/tests/gvariant.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/glib/gvariant.c b/glib/gvariant.c index 2e288af..30a3280 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -5987,7 +5987,7 @@ g_variant_byteswap (GVariant *value) if (alignment) /* (potentially) contains multi-byte numeric data */ { - GVariantSerialised serialised; + GVariantSerialised serialised = { 0, }; GVariant *trusted; GBytes *bytes; diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c index 31a7dde..2f33a3e 100644 --- a/glib/tests/gvariant.c +++ b/glib/tests/gvariant.c @@ -1442,7 +1442,7 @@ test_maybe (void) for (flavour = 0; flavour < 8; flavour += alignment) { - GVariantSerialised serialised; + GVariantSerialised serialised = { 0, }; GVariantSerialised child; serialised.type_info = type_info; @@ -1568,7 +1568,7 @@ test_array (void) for (flavour = 0; flavour < 8; flavour += alignment) { - GVariantSerialised serialised; + GVariantSerialised serialised = { 0, }; serialised.type_info = array_info; serialised.data = flavoured_malloc (needed_size, flavour); @@ -1734,7 +1734,7 @@ test_tuple (void) for (flavour = 0; flavour < 8; flavour += alignment) { - GVariantSerialised serialised; + GVariantSerialised serialised = { 0, }; serialised.type_info = type_info; serialised.data = flavoured_malloc (needed_size, flavour); @@ -1831,7 +1831,7 @@ test_variant (void) for (flavour = 0; flavour < 8; flavour += alignment) { - GVariantSerialised serialised; + GVariantSerialised serialised = { 0, }; GVariantSerialised child; serialised.type_info = type_info; @@ -2280,7 +2280,7 @@ serialise_tree (TreeInstance *tree, static void test_byteswap (void) { - GVariantSerialised one, two; + GVariantSerialised one = { 0, }, two = { 0, }; TreeInstance *tree; tree = tree_instance_new (NULL, 3); @@ -2354,7 +2354,7 @@ test_serialiser_children (void) static void test_fuzz (gdouble *fuzziness) { - GVariantSerialised serialised; + GVariantSerialised serialised = { 0, }; TreeInstance *tree; /* make an instance */ -- 2.40.0