From 3514077069be52de804ab9ba5c081658951bef84 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 8 Nov 2005 18:26:37 +0000 Subject: [PATCH] Ignore icons if they would make the request large enough to cause Xlib to 2005-11-08 Matthias Clasen * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Ignore icons if they would make the request large enough to cause Xlib to loose the connection. (#320909, Claudio Saavedra) --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ gdk/x11/gdkwindow-x11.c | 22 +++++++++++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06fe82a47..516c9856b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-11-08 Matthias Clasen + + * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Ignore + icons if they would make the request large enough to cause + Xlib to loose the connection. (#320909, Claudio Saavedra) + 2005-11-08 Michael Natterer * gdk/gdk.symbols diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 06fe82a47..516c9856b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2005-11-08 Matthias Clasen + + * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Ignore + icons if they would make the request large enough to cause + Xlib to loose the connection. (#320909, Claudio Saavedra) + 2005-11-08 Michael Natterer * gdk/gdk.symbols diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 1831b73de..cdbe6282f 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -4017,6 +4017,12 @@ gdk_x11_window_set_user_time (GdkWindow *window, toplevel->user_time = timestamp_long; } +#define GDK_SELECTION_MAX_SIZE(display) \ + MIN(262144, \ + XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \ + ? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \ + : XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100) + /** * gdk_window_set_icon_list: * @window: The #GdkWindow toplevel window to set the icon of. @@ -4045,6 +4051,7 @@ gdk_window_set_icon_list (GdkWindow *window, gint x, y; gint n_channels; GdkDisplay *display; + gint n; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -4055,7 +4062,7 @@ gdk_window_set_icon_list (GdkWindow *window, l = pixbufs; size = 0; - + n = 0; while (l) { pixbuf = l->data; @@ -4064,8 +4071,16 @@ gdk_window_set_icon_list (GdkWindow *window, width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); + /* silently ignore overlarge icons */ + if (size + 2 + width * height > GDK_SELECTION_MAX_SIZE(display)) + { + g_warning ("gdk_window_set_icon_list: icons too large"); + break; + } + + n++; size += 2 + width * height; - + l = g_list_next (l); } @@ -4073,7 +4088,7 @@ gdk_window_set_icon_list (GdkWindow *window, l = pixbufs; p = data; - while (l) + while (l && n > 0) { pixbuf = l->data; @@ -4106,6 +4121,7 @@ gdk_window_set_icon_list (GdkWindow *window, } l = g_list_next (l); + n--; } if (size > 0) -- 2.43.2