aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/GetProp.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-03-09 11:04:37 -0800
committerUlrich Sibiller <uli42@gmx.de>2016-10-12 09:34:38 +0200
commite03f3922a3d97174916273e369b2e9a90f53a05a (patch)
tree50f82657cb07b610548118301f2207e866c482b8 /nx-X11/lib/X11/GetProp.c
parentb20710586d97c69c47aa657c29c8df661f6fe417 (diff)
downloadnx-libs-e03f3922a3d97174916273e369b2e9a90f53a05a.tar.gz
nx-libs-e03f3922a3d97174916273e369b2e9a90f53a05a.tar.bz2
nx-libs-e03f3922a3d97174916273e369b2e9a90f53a05a.zip
Make XGetWindowProperty() always initialize returned values
Avoids memory corruption and other errors when callers access them without checking to see if XGetWindowProperty() returned an error value. Callers are still required to check for errors, this just reduces the damage when they don't. Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Signed-off-by: Julien Cristau <jcristau@debian.org> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib/X11/GetProp.c')
-rw-r--r--nx-X11/lib/X11/GetProp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/nx-X11/lib/X11/GetProp.c b/nx-X11/lib/X11/GetProp.c
index a9c357d69..4149199f5 100644
--- a/nx-X11/lib/X11/GetProp.c
+++ b/nx-X11/lib/X11/GetProp.c
@@ -49,6 +49,13 @@ XGetWindowProperty(
register xGetPropertyReq *req;
xError error;
+ /* Always initialize return values, in case callers fail to initialize
+ them and fail to check the return code for an error. */
+ *actual_type = None;
+ *actual_format = 0;
+ *nitems = *bytesafter = 0L;
+ *prop = (unsigned char *) NULL;
+
LockDisplay(dpy);
GetReq (GetProperty, req);
req->window = w;
@@ -65,7 +72,6 @@ XGetWindowProperty(
return (1); /* not Success */
}
- *prop = (unsigned char *) NULL;
if (reply.propertyType != None) {
unsigned long nbytes, netbytes;
int format = reply.format;