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

Jamey Sharp jamey at minilop.net
Fri Sep 17 09:01:45 PDT 2010


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 9a09d18..ae6d617 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 2983a87..dd00e68 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 0f122cc..821036a 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 7f9d028..ea03aed 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 c38346c..4a35799 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -343,9 +343,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.0



More information about the xorg-devel mailing list