[gnome-logs] Fix crash when users don't have proper permissions



commit a6145ed0ecc7dba8bacb4f8dc5055b27bb28ff09
Author: Jonathan Kang <jonathan121537 gmail com>
Date:   Tue Jan 24 11:05:10 2017 +0800

    Fix crash when users don't have proper permissions
    
    When users don't have permissions to view both system and user logs,
    priv->boot_match equals NULL. One common scenario is the journal storage
    type is volatile and there is no journal files under /var/log/journal.
    So don't add boot match under this scenario.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776818

 src/gl-eventviewlist.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c
index c385420..e9df282 100644
--- a/src/gl-eventviewlist.c
+++ b/src/gl-eventviewlist.c
@@ -370,6 +370,8 @@ get_uid_match_field_value (void)
 static gchar *
 get_current_boot_id (const gchar *boot_match)
 {
+    g_return_val_if_fail (boot_match != NULL, NULL);
+
     gchar *boot_value;
 
     boot_value = strchr (boot_match, '=') + 1;
@@ -545,10 +547,17 @@ query_add_journal_range_filter (GlQuery *query,
         case GL_SEARCH_POPOVER_JOURNAL_TIMESTAMP_RANGE_CURRENT_BOOT:
         {
             /* Get current boot id */
-            gchar *boot_match;
+            gchar *boot_match = NULL;
 
-            boot_match = get_current_boot_id (priv->boot_match);
-            gl_query_add_match (query, "_BOOT_ID", boot_match, GL_QUERY_SEARCH_TYPE_EXACT);
+            /* Don't add match when priv->boot_match equals NULL. This
+             * happens when users don't have permissions to view both
+             * system and user logs. */
+            if (priv->boot_match != NULL)
+            {
+                boot_match = get_current_boot_id (priv->boot_match);
+                gl_query_add_match (query, "_BOOT_ID", boot_match,
+                                    GL_QUERY_SEARCH_TYPE_EXACT);
+            }
 
             g_free (boot_match);
         }


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