[gnome-software] trivial: Add a sanity check when resolving pkgnames



commit 34086f47c275c2d310483b70a5b2b6f394938530
Author: Richard Hughes <richard hughsie com>
Date:   Wed Oct 19 20:27:51 2016 +0100

    trivial: Add a sanity check when resolving pkgnames
    
    There is a bug in appstream-glib that's triggering on Debian that causes the
    pkgname to be an empty string, which then triggers a bug in aptcc in the
    PackageKit project. Explosions ensue.

 src/plugins/gs-plugin-packagekit-refine.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index 5038720..04e162f 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -252,9 +252,17 @@ gs_plugin_packagekit_resolve_packages (GsPlugin *plugin,
                sources = gs_app_get_sources (app);
                for (j = 0; j < sources->len; j++) {
                        pkgname = g_ptr_array_index (sources, j);
+                       if (pkgname == NULL || pkgname[0] == '\0') {
+                               g_warning ("invalid pkgname '%s' for %s",
+                                          pkgname,
+                                          gs_app_get_unique_id (app));
+                               continue;
+                       }
                        g_ptr_array_add (package_ids, g_strdup (pkgname));
                }
        }
+       if (package_ids->len == 0)
+               return TRUE;
        g_ptr_array_add (package_ids, NULL);
 
        data.app = NULL;


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