summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2016-10-04 15:05:14 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2016-10-04 15:05:14 +0000
commit71c7c2d1a45d97e2fde59a6a7469b9ae53e035bb (patch)
treedb4dec255598d00171f6c6e0127307f4d8f9a261 /lib
parenta2ee4c357e901e111f8dbfb940342581aeed2df1 (diff)
Validate lengths while parsing server data.
Individual lengths inside received server data can overflow the previously reserved memory. It is therefore important to validate every single length field to not overflow the previously agreed sum of all invidual length fields. From Tobias Stoeckmann / X.Org security advisory Oct 4, 2016
Diffstat (limited to 'lib')
-rw-r--r--lib/libXrender/src/Xrender.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/libXrender/src/Xrender.c b/lib/libXrender/src/Xrender.c
index 3102eb2ef..71cf3e6d7 100644
--- a/lib/libXrender/src/Xrender.c
+++ b/lib/libXrender/src/Xrender.c
@@ -533,12 +533,30 @@ XRenderQueryFormats (Display *dpy)
screen->fallback = _XRenderFindFormat (xri, xScreen->fallback);
screen->subpixel = SubPixelUnknown;
xDepth = (xPictDepth *) (xScreen + 1);
+ if (screen->ndepths > rep.numDepths) {
+ Xfree (xri);
+ Xfree (xData);
+ _XEatDataWords (dpy, rep.length);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ rep.numDepths -= screen->ndepths;
for (nd = 0; nd < screen->ndepths; nd++)
{
depth->depth = xDepth->depth;
depth->nvisuals = xDepth->nPictVisuals;
depth->visuals = visual;
xVisual = (xPictVisual *) (xDepth + 1);
+ if (depth->nvisuals > rep.numVisuals) {
+ Xfree (xri);
+ Xfree (xData);
+ _XEatDataWords (dpy, rep.length);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ rep.numVisuals -= depth->nvisuals;
for (nv = 0; nv < depth->nvisuals; nv++)
{
visual->visual = _XRenderFindVisual (dpy, xVisual->visual);