diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-12-31 11:35:47 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-01-05 09:41:48 -0800 |
commit | ff223d5595c292f0ccee9f4690f11b29157ef3ab (patch) | |
tree | b64b5706c18b8e7728aff301fd04b6fd5207ea99 | |
parent | cd298a5f8e345791c1889bdd781fddc01c94fc1d (diff) |
Only use results from GetWindowProperty if it returned success
Since Xlib prior to 1.6 didn't always clear values on failure, don't
assume they're safe to use unless we succeeded.
Reported by Oracle Parfait 1.5.1:
Error: Uninitialised memory (CWE 456)
Possible access to uninitialised memory '&after'
at line 328 of xsetroot.c in function 'FixupState'.
&after allocated at line 317.
Possible access to uninitialised memory '&data'
at line 330 of xsetroot.c in function 'FixupState'.
&data allocated at line 318.
Possible access to uninitialised memory '&format'
at line 328 of xsetroot.c in function 'FixupState'.
&format allocated at line 316.
Possible access to uninitialised memory '&length'
at line 328 of xsetroot.c in function 'FixupState'.
&length allocated at line 317.
Possible access to uninitialised memory '&type'
at line 328 of xsetroot.c in function 'FixupState'.
&type allocated at line 315.
at line 331 of xsetroot.c in function 'FixupState'.
&type allocated at line 315.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | xsetroot.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -331,10 +331,13 @@ FixupState(void) return; prop = XInternAtom(dpy, "_XSETROOT_ID", False); if (unsave_past) { - (void)XGetWindowProperty(dpy, root, prop, 0L, 1L, True, AnyPropertyType, - &type, &format, &length, &after, &data); - if ((type == XA_PIXMAP) && (format == 32) && - (length == 1) && (after == 0)) + if (XGetWindowProperty(dpy, root, prop, 0L, 1L, True, AnyPropertyType, + &type, &format, &length, &after, &data) != Success) + fprintf(stderr, + "%s: warning: cannot get _XSETROOT_ID property from root window\n", + program_name); + else if ((type == XA_PIXMAP) && (format == 32) && + (length == 1) && (after == 0)) XKillClient(dpy, *((Pixmap *)data)); else if (type != None) fprintf(stderr, "%s: warning: _XSETROOT_ID property is garbage\n", |