[epiphany/mcatanzaro/1900656] gsb-service: don't crash when GSB database is broken




commit 4428252622efef9315b74f6091b6eb9cbde5519d
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Nov 23 14:22:07 2020 -0600

    gsb-service: don't crash when GSB database is broken
    
    Currently there are four places where we assert the GSB database is not
    broken. But some of these asserts are wrong. Two are clearly safe, and
    one is clearly not (since it was actually hit). I think the other is
    also not safe.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1900656

 lib/safe-browsing/ephy-gsb-service.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/lib/safe-browsing/ephy-gsb-service.c b/lib/safe-browsing/ephy-gsb-service.c
index 795049a3f..44c244f4c 100644
--- a/lib/safe-browsing/ephy-gsb-service.c
+++ b/lib/safe-browsing/ephy-gsb-service.c
@@ -141,7 +141,12 @@ ephy_gsb_service_schedule_update (EphyGSBService *self)
   gint64 interval;
 
   g_assert (EPHY_IS_GSB_SERVICE (self));
-  g_assert (ephy_gsb_storage_is_operable (self->storage));
+
+  if (!ephy_gsb_storage_is_operable (self->storage)) {
+    self->source_id = 0;
+    LOG ("Local GSB database is broken, cannot schedule update");
+    return;
+  }
 
   /* This function should only be called when self->next_list_updates_time is
    * greater than CURRENT_TIME. However, asserting (self->next_list_updates_time
@@ -178,7 +183,11 @@ ephy_gsb_service_update_thread (GTask          *task,
   char *body;
 
   g_assert (EPHY_IS_GSB_SERVICE (self));
-  g_assert (ephy_gsb_storage_is_operable (self->storage));
+
+  if (!ephy_gsb_storage_is_operable (self->storage)) {
+    LOG ("Local GSB database is broken, cannot update it");
+    goto out;
+  }
 
   /* Set up a default next update time in case of failure or non-existent
    * minimum wait duration.


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