Alexandre Julliard : winex11: Add some sanity checks on bitmap formats before creating a pixmap.

Alexandre Julliard julliard at winehq.org
Thu Dec 8 13:43:38 CST 2011


Module: wine
Branch: master
Commit: 2453b6a896a9bd86221422658d0f4944f37b1547
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2453b6a896a9bd86221422658d0f4944f37b1547

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec  8 10:32:51 2011 +0100

winex11: Add some sanity checks on bitmap formats before creating a pixmap.

---

 dlls/winex11.drv/bitmap.c  |   30 ++++++++++--------------------
 dlls/winex11.drv/xrender.c |    1 -
 2 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/dlls/winex11.drv/bitmap.c b/dlls/winex11.drv/bitmap.c
index 09da565..2232c49 100644
--- a/dlls/winex11.drv/bitmap.c
+++ b/dlls/winex11.drv/bitmap.c
@@ -130,6 +130,16 @@ BOOL X11DRV_create_phys_bitmap( HBITMAP hbitmap, const BITMAP *bitmap, int depth
 {
     X_PHYSBITMAP *physBitmap;
 
+    if (bitmap->bmWidth > 65535 || bitmap->bmHeight > 65535 || bitmap->bmPlanes != 1 ||
+        (bitmap->bmBitsPixel != 1 && bitmap->bmBitsPixel != screen_bpp))
+    {
+        WARN( "Trying to create invalid pixmap %dx%d planes %d bpp %d\n",
+              bitmap->bmWidth, bitmap->bmHeight, bitmap->bmPlanes, bitmap->bmBitsPixel );
+        return FALSE;
+    }
+
+    TRACE( "(%p) %dx%d %d bpp\n", hbitmap, bitmap->bmWidth, bitmap->bmHeight, bitmap->bmBitsPixel );
+
     if (!(physBitmap = X11DRV_init_phys_bitmap( hbitmap ))) return FALSE;
 
     physBitmap->depth = depth;
@@ -170,28 +180,8 @@ BOOL X11DRV_CreateBitmap( PHYSDEV dev, HBITMAP hbitmap )
 
     if (!GetObjectW( hbitmap, sizeof(bitmap), &bitmap )) return FALSE;
 
-      /* Check parameters */
-    if (bitmap.bmPlanes != 1) return FALSE;
-
-    /* check if bpp is compatible with screen depth */
-    if (!((bitmap.bmBitsPixel == 1) || (bitmap.bmBitsPixel == screen_bpp)))
-    {
-        WARN("Trying to make bitmap with planes=%d, bpp=%d\n",
-            bitmap.bmPlanes, bitmap.bmBitsPixel);
-        return FALSE;
-    }
-
-    TRACE("(%p) %dx%d %d bpp\n", hbitmap, bitmap.bmWidth, bitmap.bmHeight, bitmap.bmBitsPixel);
-
     if (bitmap.bmBitsPixel == 1)
-    {
-        if (hbitmap == BITMAP_stock_phys_bitmap.hbitmap)
-        {
-            ERR( "called for stock bitmap, please report\n" );
-            return FALSE;
-        }
         return X11DRV_create_phys_bitmap( hbitmap, &bitmap, 1, FALSE, NULL );
-    }
 
     return X11DRV_create_phys_bitmap( hbitmap, &bitmap, screen_depth,
                                       (visual->class == TrueColor || visual->class == DirectColor),
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index 21c1280..02625eb 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -1303,7 +1303,6 @@ static BOOL xrenderdrv_CreateBitmap( PHYSDEV dev, HBITMAP hbitmap )
 
     if (!GetObjectW( hbitmap, sizeof(bitmap), &bitmap )) return FALSE;
 
-    if (bitmap.bmPlanes != 1) return FALSE;
     format = get_bitmap_format( bitmap.bmBitsPixel );
 
     if (pict_formats[format])




More information about the wine-cvs mailing list