summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-12-31 00:49:34 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-12-31 00:49:34 -0800
commit032fc6a734516189e11b43e0b4680d15b62c5e66 (patch)
treeed3f868d62dac85771ceef16696f5910f7152ca1
parent76f6ad6e96b1ce62a32767bc0478a17b8b9204d7 (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 '&nPixels' at line 963 of src/parse.c in function 'put_pixel_on_root'. &nPixels allocated at line 953. Possible access to uninitialised memory '&retProp' at line 962 of src/parse.c in function 'put_pixel_on_root'. &retProp allocated at line 954. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/parse.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/parse.c b/src/parse.c
index 6ae9685..787e1b1 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -954,16 +954,15 @@ put_pixel_on_root(Pixel pixel)
unsigned char*retProp;
Pixel *pixelProp;
pixelAtom = XInternAtom(dpy, "_MIT_PRIORITY_COLORS", True);
- XGetWindowProperty(dpy, Scr->Root, pixelAtom, 0, 8192,
- False, XA_CARDINAL, &retAtom,
- &retFormat, &nPixels, &retAfter,
- &retProp);
-
- pixelProp = (Pixel *) retProp;
- for (i=0; i< nPixels; i++)
- if (pixel == pixelProp[i])
- addPixel = 0;
-
+ if (XGetWindowProperty(dpy, Scr->Root, pixelAtom, 0, 8192,
+ False, XA_CARDINAL, &retAtom,
+ &retFormat, &nPixels, &retAfter,
+ &retProp) == Success) {
+ pixelProp = (Pixel *) retProp;
+ for (i = 0; i < nPixels; i++)
+ if (pixel == pixelProp[i])
+ addPixel = 0;
+ }
if (addPixel)
XChangeProperty (dpy, Scr->Root, _XA_MIT_PRIORITY_COLORS,
XA_CARDINAL, 32, PropModeAppend,