[Xfce4-commits] <xfdesktop:xfce-4.10> fix use-after-free in xfdesktop_regular_file_icon_peek_tooltip

Jérôme Guelfucci noreply at xfce.org
Sun Aug 5 16:56:01 CEST 2012


Updating branch refs/heads/xfce-4.10
         to ae6a1ce26a1074810dce71e2d8a821623aa67a56 (commit)
       from d77079e03fd39d99455ff4f6495cbc6a5cc53308 (commit)

commit ae6a1ce26a1074810dce71e2d8a821623aa67a56
Author: Stefan Seyfried <seife+obs at b1-systems.com>
Date:   Wed Jun 27 09:42:55 2012 +0200

    fix use-after-free in xfdesktop_regular_file_icon_peek_tooltip
    
    xfce_rc_close() actually free()s "comment", so it needs to come after
    we have strdup()ed its contents, not before.
    This was introduced in commit 2fac2c92 (fix for bug 8509)
    Fixes bug 9059.

 src/xfdesktop-regular-file-icon.c |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/xfdesktop-regular-file-icon.c b/src/xfdesktop-regular-file-icon.c
index ff5d074..6e4b71d 100644
--- a/src/xfdesktop-regular-file-icon.c
+++ b/src/xfdesktop-regular-file-icon.c
@@ -552,6 +552,10 @@ xfdesktop_regular_file_icon_peek_tooltip(XfdesktopIcon *icon)
                                                  G_FILE_ATTRIBUTE_TIME_MODIFIED);
         time_string = xfdesktop_file_utils_format_time_for_display(mtime);
 
+        regular_file_icon->priv->tooltip =
+            g_strdup_printf(_("Type: %s\nSize: %s\nLast modified: %s"),
+                            description, size_string, time_string);
+
         /* Extract the Comment entry from the .desktop file */
         if(is_desktop_file)
         {
@@ -563,23 +567,18 @@ xfdesktop_regular_file_icon_peek_tooltip(XfdesktopIcon *icon)
                 xfce_rc_set_group(rcfile, "Desktop Entry");
                 comment = xfce_rc_read_entry(rcfile, "Comment", NULL);
             }
+            /* Prepend the comment to the tooltip */
+            if(comment != NULL) {
+                gchar *tooltip = regular_file_icon->priv->tooltip;
+                regular_file_icon->priv->tooltip = g_strdup_printf("%s\n%s",
+                                                                   comment,
+                                                                   tooltip);
+                g_free(tooltip);
+            }
 
             xfce_rc_close(rcfile);
         }
 
-        regular_file_icon->priv->tooltip =
-            g_strdup_printf(_("Type: %s\nSize: %s\nLast modified: %s"),
-                            description, size_string, time_string);
-
-        /* Prepend the comment to the tooltip */
-        if(is_desktop_file && comment != NULL) {
-            gchar *tooltip = regular_file_icon->priv->tooltip;
-            regular_file_icon->priv->tooltip = g_strdup_printf("%s\n%s",
-                                                               comment,
-                                                               tooltip);
-            g_free(tooltip);
-        }
-
         g_free(time_string);
         g_free(size_string);
         g_free(description);


More information about the Xfce4-commits mailing list