[gnome-software/gnome-3-22] Check the version in the flatpakref file format



commit 855545d4da3aba830e0b81ab9ba362b9c2f15f50
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 |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 0522c3a..408de69 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -2331,6 +2331,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;
 
@@ -2344,6 +2345,24 @@ 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)) {
+               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]