Ernestas Kulik e6ffee7
From 85b687098bcedb67285ab787b8bd506d328c34e0 Mon Sep 17 00:00:00 2001
Ernestas Kulik e6ffee7
From: Ernestas Kulik <ekulik@redhat.com>
Ernestas Kulik e6ffee7
Date: Tue, 25 Aug 2020 15:17:54 +0300
Ernestas Kulik e6ffee7
Subject: [PATCH] gui-wizard-gtk: wizard: Fix invalid memory read
Ernestas Kulik e6ffee7
MIME-Version: 1.0
Ernestas Kulik e6ffee7
Content-Type: text/plain; charset=UTF-8
Ernestas Kulik e6ffee7
Content-Transfer-Encoding: 8bit
Ernestas Kulik e6ffee7
Ernestas Kulik e6ffee7
This partially reverts 7aba6e53bbfeedaacd95bbaa5e0c5e325a3e6a8d, which
Ernestas Kulik e6ffee7
results in “event” being inappropriately freed before a “goto” statement
Ernestas Kulik e6ffee7
is executed and the value stored in “g_event_selected” is read.
Ernestas Kulik e6ffee7
---
Ernestas Kulik e6ffee7
 src/gui-wizard-gtk/wizard.c | 6 +++++-
Ernestas Kulik e6ffee7
 1 file changed, 5 insertions(+), 1 deletion(-)
Ernestas Kulik e6ffee7
Ernestas Kulik e6ffee7
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
Ernestas Kulik e6ffee7
index a4d7caa0..3e69a513 100644
Ernestas Kulik e6ffee7
--- a/src/gui-wizard-gtk/wizard.c
Ernestas Kulik e6ffee7
+++ b/src/gui-wizard-gtk/wizard.c
Ernestas Kulik e6ffee7
@@ -2635,7 +2635,7 @@ static gint select_next_page_no(gint current_page_no)
Ernestas Kulik e6ffee7
 
Ernestas Kulik e6ffee7
         log_info("%s: Looking for next event to process", __func__);
Ernestas Kulik e6ffee7
         /* (note: this frees and sets to NULL g_event_selected) */
Ernestas Kulik e6ffee7
-        g_autofree char *event = setup_next_processed_event(&g_auto_event_list);
Ernestas Kulik e6ffee7
+        char *event = setup_next_processed_event(&g_auto_event_list);
Ernestas Kulik e6ffee7
         if (!event)
Ernestas Kulik e6ffee7
         {
Ernestas Kulik e6ffee7
             current_page_no = PAGENO_EVENT_PROGRESS - 1;
Ernestas Kulik e6ffee7
@@ -2644,6 +2644,8 @@ static gint select_next_page_no(gint current_page_no)
Ernestas Kulik e6ffee7
 
Ernestas Kulik e6ffee7
         if (!get_sensitive_data_permission(event))
Ernestas Kulik e6ffee7
         {
Ernestas Kulik e6ffee7
+            free(event);
Ernestas Kulik e6ffee7
+
Ernestas Kulik e6ffee7
             cancel_processing(g_lbl_event_log, /* default message */ NULL, TERMINATE_NOFLAGS);
Ernestas Kulik e6ffee7
             current_page_no = PAGENO_EVENT_PROGRESS - 1;
Ernestas Kulik e6ffee7
             goto again;
Ernestas Kulik e6ffee7
@@ -2659,6 +2661,8 @@ static gint select_next_page_no(gint current_page_no)
Ernestas Kulik e6ffee7
 
Ernestas Kulik e6ffee7
             if (libreport_get_global_stop_on_not_reportable())
Ernestas Kulik e6ffee7
             {
Ernestas Kulik e6ffee7
+                free(event);
Ernestas Kulik e6ffee7
+
Ernestas Kulik e6ffee7
                 cancel_processing(g_lbl_event_log, msg, TERMINATE_NOFLAGS);
Ernestas Kulik e6ffee7
                 current_page_no = PAGENO_EVENT_PROGRESS - 1;
Ernestas Kulik e6ffee7
                 goto again;
Ernestas Kulik e6ffee7
-- 
Ernestas Kulik e6ffee7
2.28.0
Ernestas Kulik e6ffee7