From a4dc0d581a91303f821653cb038e56a9220cbac8 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 29 Sep 2003 22:17:16 +0000 Subject: attempt to fix this to return the data as an array of long even on 64-bit 2003-09-29 Havoc Pennington * src/async-getprop.c (async_get_property_handler): attempt to fix this to return the data as an array of long even on 64-bit as with XGetWindowProperty() breakage, bug #114035, credit to Gwenole Beauchesne for tracking down. --- ChangeLog | 7 +++++++ configure.in | 3 +++ src/async-getprop.c | 44 ++++++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6fd653cc..2934106a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-09-29 Havoc Pennington + + * src/async-getprop.c (async_get_property_handler): attempt to fix + this to return the data as an array of long even on 64-bit as with + XGetWindowProperty() breakage, bug #114035, credit to Gwenole + Beauchesne for tracking down. + 2003-09-29 Havoc Pennington * src/xprops.c (cvtINT16toInt): fix the 64-bit check not to use diff --git a/configure.in b/configure.in index fbe7ad1d..77000da1 100644 --- a/configure.in +++ b/configure.in @@ -33,6 +33,9 @@ AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(__int64) +## byte order +AC_C_BIGENDIAN + #### Warnings changequote(,)dnl diff --git a/src/async-getprop.c b/src/async-getprop.c index 3b95f133..f34ea0cd 100644 --- a/src/async-getprop.c +++ b/src/async-getprop.c @@ -347,8 +347,9 @@ async_get_property_handler (Display *dpy, break; case 32: - nbytes = reply->nItems * sizeof (CARD32); - netbytes = reply->nItems << 2; + /* NOTE buffer is in longs to match XGetWindowProperty() */ + nbytes = reply->nItems * sizeof (long); + netbytes = reply->nItems << 2; /* wire size is always 32 bits though */ if (nbytes + 1 > 0 && (task->data = (unsigned char *) Xmalloc ((unsigned)nbytes + 1))) { @@ -356,10 +357,41 @@ async_get_property_handler (Display *dpy, printf ("%s: already read %d bytes using %ld more, eating %ld more\n", __FUNCTION__, bytes_read, nbytes, netbytes); #endif - /* _XRead32 (dpy, (long *) task->data, netbytes); */ - _XGetAsyncData (dpy, task->data, buf, len, - bytes_read, nbytes, - netbytes); + + /* We have to copy the XGetWindowProperty() crackrock + * and get format 32 as long even on 64-bit platforms. + */ + if (sizeof (long) == 8) + { + unsigned char *netdata; + unsigned char *lptr; + unsigned char *end_lptr; + + /* Store the 32-bit values in the end of the array */ + netdata = task->data + nbytes / 2; + + _XGetAsyncData (dpy, netdata, buf, len, + bytes_read, netbytes, + netbytes); + + /* Now move the 32-bit values to the front */ + + lptr = task->data; + end_lptr = task->data + nbytes; + while (lptr != end_lptr) + { + *(long*) lptr = *(CARD32*) netdata; + lptr += sizeof (long); + netdata += sizeof (CARD32); + } + } + else + { + /* Here the wire format matches our actual format */ + _XGetAsyncData (dpy, task->data, buf, len, + bytes_read, netbytes, + netbytes); + } } break; -- cgit v1.2.1