Re: [PATCH] wmclient.cc: GetFullWindowProperty(): programming error
Stanislav Maslovski <[email protected]> Mon, 9 Aug 2010 11:21:20 +0400
| Newsgroups | gmane.comp.window-managers.icewm.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I see that nobody will do it, unless I do it myself, therefore here goes the patch against 1.3.7pre2 branch. It should work on 64 bit processors too, however I tested it only on i386. The reason for this patch is in my previous mail. The patch corrects a long-standing programming mistake and also removes unnecessary and buggy code introduced later. Please consider this for inclusion. I also CC this to Eduard Bloch as he seems to have a magic ability to wake up Marko from his eternal sleep :) PS: now goes with the attachment, sorry for the noise. -- Stanislav ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ Icewm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/icewm-devel
get-full-window-property-fix
(text/plain, 1.4 KB)
Index: icewm-1.3.7~pre2/src/wmclient.cc
===================================================================
--- icewm-1.3.7~pre2.orig/src/wmclient.cc 2010-08-05 21:26:36.000000000 +0400
+++ icewm-1.3.7~pre2/src/wmclient.cc 2010-08-05 22:35:33.000000000 +0400
@@ -1042,20 +1042,12 @@
unsigned char *prop;
while (XGetWindowProperty(display, handle,
- propAtom, 0, 16384*32, False, AnyPropertyType,
+ propAtom, (itemCount * itemSize) / 32, 1024*32, False, AnyPropertyType,
&r_type, &r_format, &nitems, &bytes_remain,
- &prop) == Success && prop && bytes_remain == 0)
+ &prop) == Success && prop)
{
if (r_format == itemSize1 && nitems > 0) {
data = realloc(data, (itemCount + nitems) * itemSize / 8);
-
- // access to memory beyound 256MiB causes crashes! But anyhow, size
- // >>2MiB looks suspicious. Detect this case ASAP. However, if
- // the usable icon is somewhere in the beginning, it's okay to
- // return truncated data.
- if(itemCount * itemSize / 8 >= 2097152)
- break;
-
memcpy((char *)data + itemCount * itemSize / 8, prop, nitems * itemSize / 8);
itemCount += nitems;
XFree(prop);