diff options
Diffstat (limited to 'dist')
-rw-r--r-- | dist/xcb-util/icccm/icccm.c | 17 | ||||
-rw-r--r-- | dist/xcb-util/icccm/xcb_icccm.h | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/dist/xcb-util/icccm/icccm.c b/dist/xcb-util/icccm/icccm.c index 6f9463fa7..3b85cc8f1 100644 --- a/dist/xcb-util/icccm/icccm.c +++ b/dist/xcb-util/icccm/icccm.c @@ -442,14 +442,16 @@ xcb_get_wm_size_hints_from_reply(xcb_size_hints_t *hints, xcb_get_property_reply length = xcb_get_property_value_length(reply) / (reply->format / 8); if (!(reply->type == WM_SIZE_HINTS && - (reply->format == 8 || reply->format == 16 || - reply->format == 32) && + reply->format == 32 && /* OldNumPropSizeElements = 15 (pre-ICCCM) */ length >= 15)) return 0; + if (length > XCB_NUM_WM_SIZE_HINTS_ELEMENTS) + length = XCB_NUM_WM_SIZE_HINTS_ELEMENTS; + memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value (reply), - length * reply->format >> 3); + length * (reply->format / 8)); flags = (XCB_SIZE_HINT_US_POSITION | XCB_SIZE_HINT_US_SIZE | XCB_SIZE_HINT_P_POSITION | XCB_SIZE_HINT_P_SIZE | @@ -632,17 +634,18 @@ xcb_get_wm_hints_from_reply(xcb_wm_hints_t *hints, { int length, num_elem; - if(!reply) + if(!reply || reply->type != WM_HINTS || reply->format != 32) return 0; length = xcb_get_property_value_length(reply); num_elem = length / (reply->format / 8); - if (reply->type != WM_HINTS - || reply->format != 32 - || num_elem < XCB_NUM_WM_HINTS_ELEMENTS - 1) + if(num_elem < XCB_NUM_WM_HINTS_ELEMENTS - 1) return 0; + if (length > sizeof(xcb_size_hints_t)) + length = sizeof(xcb_size_hints_t); + memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value(reply), length); if(num_elem < XCB_NUM_WM_HINTS_ELEMENTS) diff --git a/dist/xcb-util/icccm/xcb_icccm.h b/dist/xcb-util/icccm/xcb_icccm.h index 938fecb4b..f75e39663 100644 --- a/dist/xcb-util/icccm/xcb_icccm.h +++ b/dist/xcb-util/icccm/xcb_icccm.h @@ -447,6 +447,8 @@ typedef struct { uint32_t win_gravity; } xcb_size_hints_t; +#define XCB_NUM_WM_SIZE_HINTS_ELEMENTS 18 + /** * @brief Set size hints to a given position. * @param hints SIZE_HINTS structure. |