[PATCH 1/3] _NET_WM_ICON: Fix the length check

Uli Schlachter psychon at znc.in
Fri Mar 11 02:35:07 PST 2011


expected_len is the expected length in number-of-pixels, but r_value_len is the
number of bytes in the reply. Since a pixel consists of 4 bytes, we have to
divide the number of bytes by 4 to get the number of pixels.

Signed-off-by: Uli Schlachter <psychon at znc.in>
---
 ewmh/ewmh.c.m4 |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ewmh/ewmh.c.m4 b/ewmh/ewmh.c.m4
index 23df1b0..176ba19 100644
--- a/ewmh/ewmh.c.m4
+++ b/ewmh/ewmh.c.m4
@@ -1154,9 +1154,9 @@ xcb_ewmh_get_wm_icon_from_reply(xcb_ewmh_get_wm_icon_reply_t *wm_icon,
     return 0;
 
   /* Check that the property is as long as it should be, handling
-     integer overflow */
+     integer overflow. "-2" to handle the width and height fields. */
   const uint64_t expected_len = r_value[0] * (uint64_t) r_value[1];
-  if(!r_value[0] || !r_value[1] || expected_len > r_value_len - 2)
+  if(!r_value[0] || !r_value[1] || expected_len > r_value_len / 4 - 2)
     return 0;
 
   wm_icon->_reply = r;
-- 
1.7.2.3


--------------090907060109020503090309
Content-Type: text/x-diff;
 name="0002-Return-more-icons-from-_NET_WM_ICON.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0002-Return-more-icons-from-_NET_WM_ICON.patch"



More information about the Xcb mailing list