[gnome-software/wip/kalev/rhbz1749566: 3/3] packagekit: Be more defensive against NULL repo ID



commit de3e7ac3776a79fc91ef7539bfb9e7d4b7ade37d
Author: Kalev Lember <klember redhat com>
Date:   Tue Sep 24 10:54:59 2019 +0200

    packagekit: Be more defensive against NULL repo ID
    
    Error out early instead of trying to pass NULL to packagekit and ending
    up with a gibberish "failed to find [Invalid UTF-8]" error message +
    critical warnings.
    
    The previous commit fixed the actual issue that led to this so hopefully
    end users never see the error.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1749566

 plugins/packagekit/gs-plugin-packagekit.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index e51a2666..2c4e1644 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -181,12 +181,22 @@ gs_plugin_app_origin_repo_enable (GsPlugin *plugin,
        GsPluginData *priv = gs_plugin_get_data (plugin);
        g_autoptr(GsPackagekitHelper) helper = gs_packagekit_helper_new (plugin);
        g_autoptr(PkResults) results = NULL;
+       const gchar *repo_id;
+
+       repo_id = gs_app_get_origin (app);
+       if (repo_id == NULL) {
+               g_set_error_literal (error,
+                                    GS_PLUGIN_ERROR,
+                                    GS_PLUGIN_ERROR_NOT_SUPPORTED,
+                                    "origin not set");
+               return FALSE;
+       }
 
        /* do sync call */
        gs_plugin_status_update (plugin, app, GS_PLUGIN_STATUS_WAITING);
        g_mutex_lock (&priv->task_mutex);
        results = pk_client_repo_enable (PK_CLIENT (priv->task),
-                                        gs_app_get_origin (app),
+                                        repo_id,
                                         TRUE,
                                         cancellable,
                                         gs_packagekit_helper_cb, helper,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]