Guest User

destroynotify-iterator-uaf.patch

a guest
May 1st, 2026
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.42 KB | None | 0 0
  1. From: zackattackz
  2. Subject: [PATCH] systray: fix iterator UAF in DestroyNotify handler
  3.  
  4. handle_x_event() iterates systray.list_icons in the DestroyNotify case to
  5. find the matching tray icon, then calls systray_destroy_event() on it.
  6. systray_destroy_event() calls remove_icon(), which g_slist_remove()s and
  7. g_free()s the current node. The loop then advances via it = it->next on
  8. the freed node, and the next iteration dereferences it->data on garbage
  9. memory (SIGSEGV).
  10.  
  11. Triggered by any tray client that destroys its window while registered --
  12. observed with Vesktop (Discord) on quit.
  13.  
  14. Fix: break out of the loop after systray_destroy_event(). Window XIDs are
  15. unique in systray.list_icons (enforced by add_icon()), so once the matching
  16. icon is found and removed there is nothing further to iterate.
  17.  
  18. This is the same iterator-invalidation pattern as the sibling bug in
  19. on_change_systray() in systraybar.c.
  20. ---
  21. src/main.c | 4 +++-
  22.  1 file changed, 3 insertions(+), 1 deletion(-)
  23.  
  24. diff --git a/src/main.c b/src/main.c
  25. --- a/src/main.c
  26. +++ b/src/main.c
  27. @@ -540,8 +540,10 @@
  28.              break;
  29.          for (GSList *it = systray.list_icons; it; it = it->next)
  30.          {
  31. -            if (((TrayWindow *)it->data)->win == e->xany.window)
  32. +            if (((TrayWindow *)it->data)->win == e->xany.window) {
  33.                  systray_destroy_event(it->data);
  34. +                break;
  35. +            }
  36.          }
  37.          break;
  38.  
Advertisement
Add Comment
Please, Sign In to add comment