[gnome-software] Check the version in the flatpakref file format
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Check the version in the flatpakref file format
- Date: Tue, 13 Dec 2016 14:24:20 +0000 (UTC)
commit ed868eab1662659253100af0f632b74ad77e50e3
Author: Richard Hughes <richard hughsie com>
Date: Tue Dec 13 14:17:42 2016 +0000
Check the version in the flatpakref file format
src/plugins/gs-flatpak.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 3465cf2..f1fef01 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -2515,6 +2515,7 @@ gs_flatpak_file_to_app_ref (GsFlatpak *self,
g_autoptr(GBytes) ref_file_data = NULL;
g_autoptr(GsApp) app = NULL;
g_autoptr(FlatpakRemote) xremote = NULL;
+ g_autoptr(GKeyFile) kf = NULL;
g_autofree gchar *origin_url = NULL;
g_autofree gchar *origin_title = NULL;
@@ -2529,6 +2530,25 @@ gs_flatpak_file_to_app_ref (GsFlatpak *self,
return FALSE;
}
+ /* load the file */
+ kf = g_key_file_new ();
+ if (!g_key_file_load_from_data (kf, contents, len, G_KEY_FILE_NONE, error)) {
+ gs_utils_error_convert_gio (error);
+ return FALSE;
+ }
+
+ /* check version */
+ if (g_key_file_has_key (kf, "Flatpak Ref", "Version", NULL)) {
+ guint64 ver = g_key_file_get_uint64 (kf, "Flatpak Ref", "Version", NULL);
+ if (ver != 1) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
+ "unsupported version %" G_GUINT64_FORMAT, ver);
+ return FALSE;
+ }
+ }
+
/* install the remote, but not the app */
ref_file_data = g_bytes_new (contents, len);
xref = flatpak_installation_install_ref_file (self->installation,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]