forked from AuroraMiddleware/gtk
Warn if length overflows. (#161520, Ian Wienand)
2005-05-18 Matthias Clasen <mclasen@redhat.com> * gdk/x11/gdkproperty-x11.c (gdk_property_get): Warn if length overflows. (#161520, Ian Wienand)
This commit is contained in:
parent
e7fc60f78f
commit
f6906b8272
@ -1,5 +1,8 @@
|
|||||||
2005-05-18 Matthias Clasen <mclasen@redhat.com>
|
2005-05-18 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gdk/x11/gdkproperty-x11.c (gdk_property_get): Warn if
|
||||||
|
length overflows. (#161520, Ian Wienand)
|
||||||
|
|
||||||
* gtk/gtktoolbutton.c (gtk_tool_button_set_icon_name): Fix
|
* gtk/gtktoolbutton.c (gtk_tool_button_set_icon_name): Fix
|
||||||
parameter names to make gtk-doc happy.
|
parameter names to make gtk-doc happy.
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2005-05-18 Matthias Clasen <mclasen@redhat.com>
|
2005-05-18 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gdk/x11/gdkproperty-x11.c (gdk_property_get): Warn if
|
||||||
|
length overflows. (#161520, Ian Wienand)
|
||||||
|
|
||||||
* gtk/gtktoolbutton.c (gtk_tool_button_set_icon_name): Fix
|
* gtk/gtktoolbutton.c (gtk_tool_button_set_icon_name): Fix
|
||||||
parameter names to make gtk-doc happy.
|
parameter names to make gtk-doc happy.
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2005-05-18 Matthias Clasen <mclasen@redhat.com>
|
2005-05-18 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gdk/x11/gdkproperty-x11.c (gdk_property_get): Warn if
|
||||||
|
length overflows. (#161520, Ian Wienand)
|
||||||
|
|
||||||
* gtk/gtktoolbutton.c (gtk_tool_button_set_icon_name): Fix
|
* gtk/gtktoolbutton.c (gtk_tool_button_set_icon_name): Fix
|
||||||
parameter names to make gtk-doc happy.
|
parameter names to make gtk-doc happy.
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
2005-05-18 Matthias Clasen <mclasen@redhat.com>
|
2005-05-18 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gdk/tmpl/properties.sgml: Updates.
|
||||||
|
|
||||||
* gtk/migrating-checklist.sgml: Add a section about named
|
* gtk/migrating-checklist.sgml: Add a section about named
|
||||||
icons.
|
icons.
|
||||||
|
|
||||||
|
@ -42,6 +42,9 @@ data commonly stored in X window properties.
|
|||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION Stability_Level ##### -->
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### STRUCT GdkAtom ##### -->
|
<!-- ##### STRUCT GdkAtom ##### -->
|
||||||
<para>
|
<para>
|
||||||
An opaque type representing a string as an index into a table
|
An opaque type representing a string as an index into a table
|
||||||
@ -252,15 +255,14 @@ and %GDK_NONE will be stored in @actual_property_type.
|
|||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
The <function>XGetWindowProperty()</function>
|
The XGetWindowProperty() function that gdk_property_get()
|
||||||
function that gdk_property_get()
|
uses has a very confusing and complicated set of semantics.
|
||||||
uses has a very confusing and complicated set of semantics.
|
|
||||||
Unfortunately, gdk_property_get() makes the situation
|
Unfortunately, gdk_property_get() makes the situation
|
||||||
worse instead of better (the semantics should be considered
|
worse instead of better (the semantics should be considered
|
||||||
undefined), and also prints warnings to stderr in cases where it
|
undefined), and also prints warnings to stderr in cases where it
|
||||||
should return a useful error to the program. You are advised to use
|
should return a useful error to the program. You are advised to use
|
||||||
<function>XGetWindowProperty()</function>
|
XGetWindowProperty() directly until a replacement function for
|
||||||
directly until a replacement function for gdk_property_get()
|
gdk_property_get()
|
||||||
is provided.
|
is provided.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
@ -273,18 +275,24 @@ is provided.
|
|||||||
be filled in, a warning will be printed to stderr
|
be filled in, a warning will be printed to stderr
|
||||||
and no data will be returned.
|
and no data will be returned.
|
||||||
@offset: the offset into the property at which to begin
|
@offset: the offset into the property at which to begin
|
||||||
retrieving data. (in 4 byte units!)
|
retrieving data, in 4 byte units.
|
||||||
@length: the length of the data to delete. (in bytes, but
|
@length: the length of the data to retrieve in bytes. Data is
|
||||||
the actual retrieved length will be the next
|
considered to be retrieved in 4 byte chunks, so @length
|
||||||
integer multiple multiple of four greater than
|
will be rounded up to the next highest 4 byte boundary
|
||||||
this!)
|
(so be careful not to pass a value that might overflow
|
||||||
|
when rounded up).
|
||||||
@pdelete: if %TRUE, delete the property after retrieving the
|
@pdelete: if %TRUE, delete the property after retrieving the
|
||||||
data.
|
data.
|
||||||
@actual_property_type: location to store the actual type of
|
@actual_property_type: location to store the actual type of
|
||||||
the property.
|
the property.
|
||||||
@actual_format: location to store the actual format of the data.
|
@actual_format: location to store the actual return format of the
|
||||||
@actual_length: location to store the length of the retrieved
|
data; either 8, 16 or 32 bits.
|
||||||
data, in bytes.
|
@actual_length: location to store the length of the retrieved data, in
|
||||||
|
bytes. Data returned in the 32 bit format is stored
|
||||||
|
in a long variable, so the actual number of 32 bit
|
||||||
|
elements should be be calculated via
|
||||||
|
@actual_length/sizeof(glong) to ensure portability to
|
||||||
|
64 bit systems.
|
||||||
@data: location to store a pointer to the data. The retrieved
|
@data: location to store a pointer to the data. The retrieved
|
||||||
data should be freed with g_free() when you are finished
|
data should be freed with g_free() when you are finished
|
||||||
using it.
|
using it.
|
||||||
|
@ -493,6 +493,7 @@ gdk_property_get (GdkWindow *window,
|
|||||||
gint ret_format;
|
gint ret_format;
|
||||||
gulong ret_nitems;
|
gulong ret_nitems;
|
||||||
gulong ret_bytes_after;
|
gulong ret_bytes_after;
|
||||||
|
gulong get_length;
|
||||||
gulong ret_length;
|
gulong ret_length;
|
||||||
guchar *ret_data;
|
guchar *ret_data;
|
||||||
Atom xproperty;
|
Atom xproperty;
|
||||||
@ -521,9 +522,30 @@ gdk_property_get (GdkWindow *window,
|
|||||||
|
|
||||||
ret_data = NULL;
|
ret_data = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Round up length to next 4 byte value. Some code is in the (bad?)
|
||||||
|
* habit of passing G_MAXLONG as the length argument, causing an
|
||||||
|
* overflow to negative on the add. In this case, we clamp the
|
||||||
|
* value to G_MAXLONG.
|
||||||
|
*/
|
||||||
|
get_length = length + 3;
|
||||||
|
if (get_length > G_MAXLONG)
|
||||||
|
{
|
||||||
|
g_warning ("gdk_property_get(): length value has wrapped in calculation "
|
||||||
|
"(did you pass G_MAXLONG?)");
|
||||||
|
get_length = G_MAXLONG;
|
||||||
|
}
|
||||||
|
/* To fail, either the user passed 0 or G_MAXULONG */
|
||||||
|
get_length = get_length / 4;
|
||||||
|
if (get_length == 0)
|
||||||
|
{
|
||||||
|
g_warning ("gdk_propery-get(): invalid length 0");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
res = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
|
res = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
|
||||||
GDK_WINDOW_XWINDOW (window), xproperty,
|
GDK_WINDOW_XWINDOW (window), xproperty,
|
||||||
offset, (length + 3) / 4, pdelete,
|
offset, get_length, pdelete,
|
||||||
xtype, &ret_prop_type, &ret_format,
|
xtype, &ret_prop_type, &ret_format,
|
||||||
&ret_nitems, &ret_bytes_after,
|
&ret_nitems, &ret_bytes_after,
|
||||||
&ret_data);
|
&ret_data);
|
||||||
|
Loading…
Reference in New Issue
Block a user