[PATCH 3/3] Move pixmap size limit checking to CreatePixmap, from screen hooks.

Jamey Sharp jamey at minilop.net
Sat Oct 1 23:08:48 PDT 2011


Commit by Jamey Sharp and Josh Triplett.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
Signed-off-by: Josh Triplett <josh at joshtriplett.org>
---
 dix/pixmap.c             |    7 ++++++-
 exa/exa_classic.c        |    3 ---
 exa/exa_driver.c         |    5 -----
 exa/exa_mixed.c          |    5 -----
 fb/fbpixmap.c            |    2 --
 hw/xfree86/xaa/xaaInit.c |    3 ---
 6 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/dix/pixmap.c b/dix/pixmap.c
index 232188c..e6654f4 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -108,7 +108,12 @@ FreeScratchPixmapsForScreen(int scrnum)
 PixmapPtr
 CreatePixmap(ScreenPtr pScreen, int width, int height, int depth, unsigned usage_hint)
 {
-    PixmapPtr pPixmap = dixAllocateObjectWithPrivates(PixmapRec, PRIVATE_PIXMAP);
+    PixmapPtr pPixmap;
+
+    if (width > 32767 || height > 32767)
+	return NullPixmap;
+
+    pPixmap = dixAllocateObjectWithPrivates(PixmapRec, PRIVATE_PIXMAP);
     if (!pPixmap)
         return NullPixmap;
     pPixmap->drawable.type = DRAWABLE_PIXMAP;
diff --git a/exa/exa_classic.c b/exa/exa_classic.c
index a40f3aa..8d740ab 100644
--- a/exa/exa_classic.c
+++ b/exa/exa_classic.c
@@ -64,9 +64,6 @@ exaCreatePixmap_classic(PixmapPtr pPixmap)
     Bool ret;
     ExaScreenPriv(pScreen);
 
-    if (w > 32767 || h > 32767)
-	return FALSE;
-
     swap(pExaScr, pScreen, CreatePixmap);
     ret = pScreen->CreatePixmap (pPixmap);
     swap(pExaScr, pScreen, CreatePixmap);
diff --git a/exa/exa_driver.c b/exa/exa_driver.c
index 5b74d73..a9f1e19 100644
--- a/exa/exa_driver.c
+++ b/exa/exa_driver.c
@@ -58,9 +58,6 @@ exaCreatePixmap_driver(PixmapPtr pPixmap)
     size_t paddedWidth, datasize;
     ExaScreenPriv(pScreen);
 
-    if (w > 32767 || h > 32767)
-	return FALSE;
-
     swap(pExaScr, pScreen, CreatePixmap);
     ret = pScreen->CreatePixmap(pPixmap);
     swap(pExaScr, pScreen, CreatePixmap);
@@ -85,8 +82,6 @@ exaCreatePixmap_driver(PixmapPtr pPixmap)
     }
     else {
 	paddedWidth = ((w * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
-	if (paddedWidth / 4 > 32767 || h > 32767)
-	    return FALSE;
 
 	exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
 
diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
index 2e6eea2..851f062 100644
--- a/exa/exa_mixed.c
+++ b/exa/exa_mixed.c
@@ -57,9 +57,6 @@ exaCreatePixmap_mixed(PixmapPtr pPixmap)
     size_t paddedWidth;
     ExaScreenPriv(pScreen);
 
-    if (w > 32767 || h > 32767)
-	return FALSE;
-
     swap(pExaScr, pScreen, CreatePixmap);
     ret = pScreen->CreatePixmap(pPixmap);
     swap(pExaScr, pScreen, CreatePixmap);
@@ -73,8 +70,6 @@ exaCreatePixmap_mixed(PixmapPtr pPixmap)
     bpp = pPixmap->drawable.bitsPerPixel;
 
     paddedWidth = ((w * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
-    if (paddedWidth / 4 > 32767 || h > 32767)
-        return FALSE;
 
     /* We will allocate the system pixmap later if needed. */
     pPixmap->devPrivate.ptr = NULL;
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index f135109..08bc91a 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -35,8 +35,6 @@ fbCreatePixmapBpp (PixmapPtr pPixmap, int bpp)
     size_t	paddedWidth;
 
     paddedWidth = ((pPixmap->drawable.width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
-    if (paddedWidth / 4 > 32767 || pPixmap->drawable.height > 32767)
-	return FALSE;
     datasize = pPixmap->drawable.height * paddedWidth;
 #ifdef FB_DEBUG
     datasize += 2 * paddedWidth;
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 5770a81..9846f4b 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -340,9 +340,6 @@ XAACreatePixmap(PixmapPtr pPix)
     int h = pPix->drawable.height;
     int size = w * h;
 
-    if (w > 32767 || h > 32767)
-	return FALSE;
-    
     if (!infoRec->offscreenDepthsInitialized)
 	XAAInitializeOffscreenDepths (pScreen);
 
-- 
1.7.5.4



More information about the xorg-devel mailing list