From 1eed25617cf74e5dbbbcd18380188a3b8b8b7aa0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 28 Oct 2022 11:54:36 +0100 Subject: Replace calls to g_memdup() with g_memdup2() g_memdup() is subject to an integer overflow on 64-bit machines if the object being copied is larger than UINT_MAX bytes. I suspect none of these objects can actually be that large in practice, but it's easier to replace all the calls than it is to assess whether we need to replace them. A backport in libglnx is used on systems where GLib is older than 2.68.x. Signed-off-by: Simon McVittie --- common/flatpak-dir.c | 2 +- common/flatpak-utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 01362a2b..946a17c8 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -13002,7 +13002,7 @@ populate_hash_table_from_refs_map (GHashTable *ret_all_refs, continue; /* New timestamp is older, skip this commit */ } - new_timestamp = g_memdup (×tamp, sizeof (guint64)); + new_timestamp = g_memdup2 (×tamp, sizeof (guint64)); } g_hash_table_replace (ret_all_refs, g_steal_pointer (&decomposed), ostree_checksum_from_bytes (csum_bytes)); diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index c89cc63b..2d8d922b 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -3662,7 +3662,7 @@ _ostree_repo_static_delta_superblock_digest (OstreeRepo *repo, g_checksum_get_digest (checksum, digest, &len); return g_variant_new_from_data (G_VARIANT_TYPE ("ay"), - g_memdup (digest, len), len, + g_memdup2 (digest, len), len, FALSE, g_free, FALSE); } -- cgit v1.2.1