[epiphany/mcatanzaro/even-more-password-cleanups] Add more early returns before calling into password manager



commit 89edcdd77e94e65f922e47ce9da50b79d5c6776f
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sun Apr 28 18:05:40 2019 -0500

    Add more early returns before calling into password manager
    
    Let's sanity-check the requests we are receiving from the web process.

 embed/ephy-embed-shell.c         | 12 +++++++++++-
 lib/sync/ephy-password-manager.c |  3 +++
 2 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 064e0605e..4fc745453 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -420,6 +420,9 @@ web_extension_password_manager_query_received_cb (WebKitUserContentManager *mana
   gint32 promise_id = property_to_int32 (value, "promiseID");
   guint64 page_id = property_to_uint64 (value, "pageID");
 
+  if (!origin || !target_origin || !password_field)
+    return;
+
   PasswordManagerData *data = g_new (PasswordManagerData, 1);
   data->shell = g_object_ref (shell);
   data->promise_id = promise_id;
@@ -496,6 +499,10 @@ web_extension_password_manager_save_real (EphyEmbedShell *shell,
   guint64 page_id = property_to_uint64 (value, "pageID");
   EphyWebView *view;
 
+  /* Both origin and target origin are required. */
+  if (!origin || !target_origin)
+    return;
+
   /* Both password and password field are required. */
   if (!password || !password_field)
     return;
@@ -566,8 +573,11 @@ web_extension_password_manager_query_usernames_received_cb (WebKitUserContentMan
   g_autofree char *origin = property_to_string_or_null (value, "origin");
   gint32 promise_id = property_to_int32 (value, "promiseID");
   guint64 page_id = property_to_uint64 (value, "pageID");
-
   GList *usernames;
+
+  if (!origin)
+    return;
+
   usernames = ephy_password_manager_get_usernames_for_origin (priv->password_manager, origin);
 
   EphyWebExtensionProxy *proxy = ephy_embed_shell_get_extension_proxy_for_page_id (shell, page_id, origin);
diff --git a/lib/sync/ephy-password-manager.c b/lib/sync/ephy-password-manager.c
index 2d138d674..ebb494307 100644
--- a/lib/sync/ephy-password-manager.c
+++ b/lib/sync/ephy-password-manager.c
@@ -586,6 +586,9 @@ ephy_password_manager_query (EphyPasswordManager              *self,
   GHashTable *attributes;
 
   g_assert (EPHY_IS_PASSWORD_MANAGER (self));
+  g_assert (origin);
+  g_assert (target_origin);
+  g_assert (password_field);
 
   LOG ("Querying password records for (%s, %s, %s, %s)",
        origin, username, username_field, password_field);


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