[epiphany/mwleeds/webapp-uninstall-segfault: 11/11] webapp-provider: Gracefully handle bad app IDs



commit 89e014c7d24cbeaa299986ee3868a7db07a3fcf5
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Tue Mar 22 18:44:47 2022 -0700

    webapp-provider: Gracefully handle bad app IDs
    
    In case the Uninstall() method was given a desktop_file_id that didn't
    have the right prefix, this was leading to a seg fault since
    get_app_id_from_gapplication_id() would return NULL when called by
    ephy_web_application_delete_by_desktop_file_id(). Fix this by adding a
    check in the D-Bus service implementation.
    
    Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1098>

 lib/ephy-web-app-utils.c                   | 3 ---
 lib/ephy-web-app-utils.h                   | 3 +++
 src/webapp-provider/ephy-webapp-provider.c | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index 756d57320..4b481197e 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -58,9 +58,6 @@
  * System web applications have a profile dir without a desktop file.
  */
 
-/* The GApplication ID must begin with the app ID for the dynamic launcher portal to work */
-static const char *EPHY_WEB_APP_GAPPLICATION_ID_PREFIX = APPLICATION_ID ".WebApp_";
-
 GQuark webapp_error_quark (void);
 G_DEFINE_QUARK (webapp - error - quark, webapp_error)
 #define WEBAPP_ERROR webapp_error_quark ()
diff --git a/lib/ephy-web-app-utils.h b/lib/ephy-web-app-utils.h
index 66530f9c0..48d9b0245 100644
--- a/lib/ephy-web-app-utils.h
+++ b/lib/ephy-web-app-utils.h
@@ -65,6 +65,9 @@ typedef enum {
 
 #define EPHY_WEB_APP_ICON_NAME "app-icon.png"
 
+/* The GApplication ID must begin with the app ID for the dynamic launcher portal to work */
+#define EPHY_WEB_APP_GAPPLICATION_ID_PREFIX APPLICATION_ID ".WebApp_"
+
 char               *ephy_web_application_get_app_id_from_name (const char *name);
 
 const char         *ephy_web_application_get_gapplication_id_from_profile_directory (const char 
*profile_dir);
diff --git a/src/webapp-provider/ephy-webapp-provider.c b/src/webapp-provider/ephy-webapp-provider.c
index 777c3a9b7..efef16d3c 100644
--- a/src/webapp-provider/ephy-webapp-provider.c
+++ b/src/webapp-provider/ephy-webapp-provider.c
@@ -169,7 +169,8 @@ handle_uninstall (EphyWebAppProvider        *skeleton,
 
   g_application_hold (G_APPLICATION (self));
 
-  if (!desktop_file_id || !g_str_has_suffix (desktop_file_id, ".desktop")) {
+  if (!desktop_file_id || !g_str_has_suffix (desktop_file_id, ".desktop") ||
+      !g_str_has_prefix (desktop_file_id, EPHY_WEB_APP_GAPPLICATION_ID_PREFIX)) {
     g_dbus_method_invocation_return_error (invocation, EPHY_WEBAPP_PROVIDER_ERROR,
                                            EPHY_WEBAPP_PROVIDER_ERROR_INVALID_ARGS,
                                            _("The desktop file ID passed ‘%s’ was not valid"),


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