[PATCH 2/2] user32: check bitmapinfo before it is used

Wolfram Sang wolfram at the-dreams.de
Tue Feb 22 01:39:27 CST 2011


bitmap_info_size() is used before the the bitmapinfo is checked for validity.
Move that check to the front and check the original info-structure, not the
copy.

Those two patches fix bug #23651 (Spiceworks Crashes during Installation) which
has broken BMPs due to bug #12838 (Spiceworks IT Desktop: Wine corrupts bitmap
files during extraction from installer).

Signed-off-by: Wolfram Sang <wolfram at the-dreams.de>
---
 dlls/user32/cursoricon.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 715e12b..f062b9c 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -2176,6 +2176,14 @@ static HBITMAP BITMAP_Load( HINSTANCE instance, LPCWSTR name,
         if (bmfh->bfOffBits) offbits = bmfh->bfOffBits - sizeof(BITMAPFILEHEADER);
     }
 
+    bm_type = DIB_GetBitmapInfo( &info->bmiHeader, &width, &height,
+                                 &bpp_dummy, &compr_dummy);
+    if (bm_type == -1)
+    {
+        WARN("Invalid bitmap format!\n");
+        goto end;
+    }
+
     size = bitmap_info_size(info, DIB_RGB_COLORS);
     fix_info = HeapAlloc(GetProcessHeap(), 0, size);
     scaled_info = HeapAlloc(GetProcessHeap(), 0, size);
@@ -2187,13 +2195,6 @@ static HBITMAP BITMAP_Load( HINSTANCE instance, LPCWSTR name,
     DIB_FixColorsToLoadflags(fix_info, loadflags, pix);
 
     memcpy(scaled_info, fix_info, size);
-    bm_type = DIB_GetBitmapInfo( &fix_info->bmiHeader, &width, &height,
-                                 &bpp_dummy, &compr_dummy);
-    if (bm_type == -1)
-    {
-        WARN("Invalid bitmap format!\n");
-        goto end;
-    }
 
     if(desiredx != 0)
         new_width = desiredx;
-- 
1.7.2.3




More information about the wine-patches mailing list