[gnome-software/gnome-3-26] packagekit: Do not crash when getting an invalid ID from PackageKit
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-26] packagekit: Do not crash when getting an invalid ID from PackageKit
- Date: Sun, 17 Dec 2017 08:53:02 +0000 (UTC)
commit a34c6c6b02291163a805ff57955fb978ce9d5a6c
Author: Richard Hughes <richard hughsie com>
Date: Sun Dec 10 14:14:23 2017 +0000
packagekit: Do not crash when getting an invalid ID from PackageKit
Fixes half of https://bugs.freedesktop.org/show_bug.cgi?id=104171
plugins/packagekit/gs-plugin-packagekit-local.c | 7 +++++++
plugins/packagekit/gs-plugin-packagekit-refine.c | 4 ++++
plugins/packagekit/gs-plugin-packagekit.c | 8 ++++++++
plugins/packagekit/gs-plugin-systemd-updates.c | 11 ++++++++++-
4 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit-local.c b/plugins/packagekit/gs-plugin-packagekit-local.c
index 0840b12..488c20c 100644
--- a/plugins/packagekit/gs-plugin-packagekit-local.c
+++ b/plugins/packagekit/gs-plugin-packagekit-local.c
@@ -210,6 +210,13 @@ gs_plugin_file_to_app (GsPlugin *plugin,
gs_plugin_get_name (plugin));
package_id = pk_details_get_package_id (item);
split = pk_package_id_split (package_id);
+ if (split == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_INVALID_FORMAT,
+ "invalid package-id: %s", package_id);
+ return FALSE;
+ }
basename = g_path_get_basename (filename);
gs_app_set_management_plugin (app, "packagekit");
gs_app_set_kind (app, AS_APP_KIND_GENERIC);
diff --git a/plugins/packagekit/gs-plugin-packagekit-refine.c
b/plugins/packagekit/gs-plugin-packagekit-refine.c
index 486f4b0..fee69a6 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refine.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refine.c
@@ -450,7 +450,11 @@ gs_pk_compare_ids (const gchar *package_id1, const gchar *package_id2)
g_auto(GStrv) split2 = NULL;
split1 = pk_package_id_split (package_id1);
+ if (split1 == NULL)
+ return FALSE;
split2 = pk_package_id_split (package_id2);
+ if (split2 == NULL)
+ return FALSE;
ret = (g_strcmp0 (split1[PK_PACKAGE_ID_NAME],
split2[PK_PACKAGE_ID_NAME]) == 0 &&
g_strcmp0 (split1[PK_PACKAGE_ID_VERSION],
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 97ba9de..4f758af 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -152,6 +152,14 @@ gs_plugin_add_sources_related (GsPlugin *plugin,
g_auto(GStrv) split = NULL;
app = gs_app_list_index (installed, i);
split = pk_package_id_split (gs_app_get_source_id_default (app));
+ if (split == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_INVALID_FORMAT,
+ "invalid package-id: %s",
+ gs_app_get_source_id_default (app));
+ return FALSE;
+ }
if (g_str_has_prefix (split[PK_PACKAGE_ID_DATA], "installed:")) {
id = split[PK_PACKAGE_ID_DATA] + 10;
app_tmp = g_hash_table_lookup (hash, id);
diff --git a/plugins/packagekit/gs-plugin-systemd-updates.c b/plugins/packagekit/gs-plugin-systemd-updates.c
index 57beae9..d703b64 100644
--- a/plugins/packagekit/gs-plugin-systemd-updates.c
+++ b/plugins/packagekit/gs-plugin-systemd-updates.c
@@ -179,12 +179,21 @@ gs_plugin_add_updates (GsPlugin *plugin,
continue;
}
+ /* get ID details */
+ split = pk_package_id_split (package_ids[i]);
+ if (split == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_INVALID_FORMAT,
+ "invalid package-id: %s", package_ids[i]);
+ return FALSE;
+ }
+
/* create new app */
app = gs_app_new (NULL);
gs_app_add_quirk (app, AS_APP_QUIRK_NEEDS_REBOOT);
gs_app_set_management_plugin (app, "packagekit");
gs_app_add_source_id (app, package_ids[i]);
- split = pk_package_id_split (package_ids[i]);
gs_app_add_source (app, split[PK_PACKAGE_ID_NAME]);
gs_app_set_update_version (app, split[PK_PACKAGE_ID_VERSION]);
gs_app_set_state (app, AS_APP_STATE_UPDATABLE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]