GNOME Bugzilla – Bug 161520
passing LONG_MAX to gdk_property_get
Last modified: 2005-08-27 04:25:48 UTC
gdk_property_get uses sizeof(long) to calculate the returned bytes. XGetWindowProperty is actually returning the number of 32 bit elements; not the number of 'long' elements so on machines with long == 8 bytes the length is incorrect. The documentation is also incorrect. This has resulted in an overflow bug described at http://bugzilla.gnome.org/show_bug.cgi?id=161512 I've attached a patch with suggested changes.
Created attachment 34925 [details] [review] Update documentation and correct incorrect use of sizeof(long)
Created attachment 34926 [details] [review] ahhh, bytes not bits :)
64-bit was implemented very strangely in Xlib ... 32 bit properties are converted into arrays of longs and GTK+ follows this convention. The overflow issue there may be a real problem... the (length + 3) / 4 rounding will produce a negative value for LONGMAX for both 32 and 64-bit values. The code probably needs to clamp the input value to avoid such overflow.
Created attachment 35179 [details] [review] Clamp G_LONGMAX value, update documentation to reflect 64 bit strangeness This patch clamps the value if it will overflow to be negative.
2005-05-18 Matthias Clasen <mclasen@redhat.com> * gdk/x11/gdkproperty-x11.c (gdk_property_get): Warn if length overflows. (#161520, Ian Wienand)
I don't think this was the right fix. G_MAXLONG has an obvious meaning "as much as you can get", and should be fixed to pass the biggest acceptable protocol value to X.
2005-08-27 Matthias Clasen <mclasen@redhat.com> * gdk/x11/gdkproperty-x11.c (gdk_property_get): Don't warn when G_MAXLONG is passed as length.