Commit 9256017a authored by Bernhard Übelacker's avatar Bernhard Übelacker Committed by Alexandre Julliard

user32: Validate DIB offset in CURSORICON_GetFileEntry.

parent 318edcc9
...@@ -678,6 +678,7 @@ static BOOL CURSORICON_GetFileEntry( LPCVOID dir, DWORD size, int n, ...@@ -678,6 +678,7 @@ static BOOL CURSORICON_GetFileEntry( LPCVOID dir, DWORD size, int n,
if ((const char *)&filedir->idEntries[n + 1] - (const char *)dir > size) if ((const char *)&filedir->idEntries[n + 1] - (const char *)dir > size)
return FALSE; return FALSE;
entry = &filedir->idEntries[n]; entry = &filedir->idEntries[n];
if (entry->dwDIBOffset > size - sizeof(info->biSize)) return FALSE;
info = (const BITMAPINFOHEADER *)((const char *)dir + entry->dwDIBOffset); info = (const BITMAPINFOHEADER *)((const char *)dir + entry->dwDIBOffset);
if (info->biSize != sizeof(BITMAPCOREHEADER)) if (info->biSize != sizeof(BITMAPCOREHEADER))
{ {
......
...@@ -1031,6 +1031,12 @@ static const unsigned char gif4pixel[42] = { ...@@ -1031,6 +1031,12 @@ static const unsigned char gif4pixel[42] = {
0x02,0x00,0x00,0x02,0x03,0x14,0x16,0x05,0x00,0x3b 0x02,0x00,0x00,0x02,0x03,0x14,0x16,0x05,0x00,0x3b
}; };
/* An invalid cursor with an invalid dwDIBOffset */
static const unsigned char invalid_dwDIBOffset[] = {
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00
};
static const DWORD biSize_tests[] = { static const DWORD biSize_tests[] = {
0, 0,
sizeof(BITMAPCOREHEADER) - 1, sizeof(BITMAPCOREHEADER) - 1,
...@@ -1320,6 +1326,8 @@ static void test_LoadImage(void) ...@@ -1320,6 +1326,8 @@ static void test_LoadImage(void)
test_LoadImageFile("BMP (broken biSize)", bmpimage, sizeof(bmpimage), "bmp", 0); test_LoadImageFile("BMP (broken biSize)", bmpimage, sizeof(bmpimage), "bmp", 0);
} }
bitmap_header->biSize = sizeof(BITMAPINFOHEADER); bitmap_header->biSize = sizeof(BITMAPINFOHEADER);
test_LoadImageFile("Cursor (invalid dwDIBOffset)", invalid_dwDIBOffset, sizeof(invalid_dwDIBOffset), "cur", 0);
} }
#undef ARRAY_SIZE #undef ARRAY_SIZE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment