[gnome-builder] flatpak-runtime: don't rely on \0 terminated strings for checksum
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak-runtime: don't rely on \0 terminated strings for checksum
- Date: Fri, 18 Nov 2016 02:57:32 +0000 (UTC)
commit 1eb88163b8e7adf63b8a298248e725c4b70fc2af
Author: Christian Hergert <chergert redhat com>
Date: Thu Nov 17 18:57:22 2016 -0800
flatpak-runtime: don't rely on \0 terminated strings for checksum
plugins/flatpak/gbp-flatpak-runtime-provider.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-runtime-provider.c b/plugins/flatpak/gbp-flatpak-runtime-provider.c
index 1d100dc..ddc57c5 100644
--- a/plugins/flatpak/gbp-flatpak-runtime-provider.c
+++ b/plugins/flatpak/gbp-flatpak-runtime-provider.c
@@ -395,19 +395,22 @@ gbp_flatpak_runtime_provider_load_manifests (GbpFlatpakRuntimeProvider *self,
g_autofree gchar *hash = NULL;
g_autofree gchar *id = NULL;
g_autofree gchar *manifest_data = NULL;
- GChecksum *checksum;
+ g_autofree gchar *path = NULL;
+ gsize manifest_data_len = 0;
+
+ path = g_file_get_path (manifest->file);
- if (g_file_get_contents (g_file_get_path (manifest->file),
- &manifest_data,
- NULL, NULL))
+ if (g_file_get_contents (path, &manifest_data, &manifest_data_len, NULL))
{
+ g_autoptr(GChecksum) checksum = NULL;
+
checksum = g_checksum_new (G_CHECKSUM_SHA1);
- g_checksum_update (checksum, (guchar *)manifest_data, -1);
+ g_checksum_update (checksum, (const guint8 *)manifest_data, manifest_data_len);
hash = g_strdup (g_checksum_get_string (checksum));
- g_checksum_free (checksum);
}
filename = g_file_get_basename (manifest->file);
+
if (hash != NULL)
id = g_strdup_printf ("%s@%s", filename, hash);
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]