From 5d8ecac1ec8d00c08b77ea25db0a9858e95e8426 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 14 Dec 2022 23:55:18 +0000 Subject: [PATCH] Make GVariantBuilder and GVariantDict layout compatible with CHERI Use guinptr instead if gsize. While this increases the structure size for Morello, it is still only 256 bytes which should not matter for a type where we expect few instances to exist at any given time. This does not increase the size for existing architectures since gsize is the same as guintptr for all of them. Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842 --- glib/gvariant.c | 4 ++-- glib/gvariant.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/glib/gvariant.c b/glib/gvariant.c index cd4c21ced..f76374915 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -3220,7 +3220,7 @@ struct heap_builder /* Just to make sure that by adding a union to GVariantBuilder, we * didn't accidentally change ABI. */ -G_STATIC_ASSERT (sizeof (GVariantBuilder) == sizeof (gsize[16])); +G_STATIC_ASSERT (sizeof (GVariantBuilder) == sizeof (guintptr[16])); static gboolean ensure_valid_builder (GVariantBuilder *builder) @@ -3907,7 +3907,7 @@ struct heap_dict /* Just to make sure that by adding a union to GVariantDict, we didn't * accidentally change ABI. */ -G_STATIC_ASSERT (sizeof (GVariantDict) == sizeof (gsize[16])); +G_STATIC_ASSERT (sizeof (GVariantDict) == sizeof (guintptr[16])); static gboolean ensure_valid_dict (GVariantDict *dict) diff --git a/glib/gvariant.h b/glib/gvariant.h index e7087a1f6..ac05d71d4 100644 --- a/glib/gvariant.h +++ b/glib/gvariant.h @@ -304,9 +304,9 @@ struct _GVariantBuilder { struct { gsize partial_magic; const GVariantType *type; - gsize y[14]; + guintptr y[14]; } s; - gsize x[16]; + guintptr x[16]; } u; }; @@ -453,9 +453,9 @@ struct _GVariantDict { struct { GVariant *asv; gsize partial_magic; - gsize y[14]; + guintptr y[14]; } s; - gsize x[16]; + guintptr x[16]; } u; };