xutil: fix possible overflow
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
62d0d08caf
commit
dfe137fab9
|
@ -40,7 +40,15 @@ xutil_get_text_property_from_reply(xcb_get_property_reply_t *reply)
|
||||||
|| reply->type == COMPOUND_TEXT)
|
|| reply->type == COMPOUND_TEXT)
|
||||||
&& reply->format == 8
|
&& reply->format == 8
|
||||||
&& xcb_get_property_value_length(reply))
|
&& xcb_get_property_value_length(reply))
|
||||||
return a_strndup(xcb_get_property_value(reply), xcb_get_property_value_length(reply));
|
{
|
||||||
|
/* We need to copy it that way since the string may not be
|
||||||
|
* NULL-terminated */
|
||||||
|
int len = xcb_get_property_value_length(reply);
|
||||||
|
char *value = p_new(char, len + 1);
|
||||||
|
memcpy(value, xcb_get_property_value(reply), len);
|
||||||
|
value[len] = '\0';
|
||||||
|
return value;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue