[gnome-software] flatpak: Handle failure of a libflatpak function updating permissions
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] flatpak: Handle failure of a libflatpak function updating permissions
- Date: Thu, 16 May 2019 15:55:09 +0000 (UTC)
commit ad93551b8661429895b448a1e3766c877c2eac4c
Author: Philip Withnall <withnall endlessm com>
Date: Thu May 16 14:03:22 2019 +0100
flatpak: Handle failure of a libflatpak function updating permissions
It’s possible for flatpak_installation_fetch_remote_metadata_sync() to
fail — if so, g_bytes_get_data(NULL) will be called, which will emit a
critical warning.
Correctly handle the error from libflatpak.
Signed-off-by: Philip Withnall <withnall endlessm com>
plugins/flatpak/gs-flatpak.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index e0668300..63634ada 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -163,6 +163,7 @@ gs_flatpak_set_update_permissions (GsFlatpak *self, GsApp *app, FlatpakInstalled
g_autoptr(GBytes) bytes = NULL;
g_autoptr(GKeyFile) keyfile = NULL;
GsAppPermissions permissions;
+ g_autoptr(GError) error_local = NULL;
old_bytes = flatpak_installed_ref_load_metadata (FLATPAK_INSTALLED_REF (xref), NULL, NULL);
old_keyfile = g_key_file_new ();
@@ -175,14 +176,21 @@ gs_flatpak_set_update_permissions (GsFlatpak *self, GsApp *app, FlatpakInstalled
gs_app_get_origin (app),
FLATPAK_REF (xref),
NULL,
- NULL);
- keyfile = g_key_file_new ();
- g_key_file_load_from_data (keyfile,
- g_bytes_get_data (bytes, NULL),
- g_bytes_get_size (bytes),
- 0, NULL);
+ &error_local);
+ if (bytes == NULL) {
+ g_debug ("Failed to get metadata for remote ‘%s’: %s",
+ gs_app_get_origin (app), error_local->message);
+ g_clear_error (&error_local);
+ permissions = GS_APP_PERMISSIONS_UNKNOWN;
+ } else {
+ keyfile = g_key_file_new ();
+ g_key_file_load_from_data (keyfile,
+ g_bytes_get_data (bytes, NULL),
+ g_bytes_get_size (bytes),
+ 0, NULL);
- permissions = perms_from_metadata (keyfile) & ~perms_from_metadata (old_keyfile);
+ permissions = perms_from_metadata (keyfile) & ~perms_from_metadata (old_keyfile);
+ }
/* no new permissions set */
if (permissions == GS_APP_PERMISSIONS_UNKNOWN)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]