Do some simple error checking on .cur and .ico file structure

svn path=/trunk/; revision=11206
This commit is contained in:
Gé van Geldorp 2004-10-05 22:08:56 +00:00
parent cdefabd236
commit 91447e78e2
2 changed files with 7 additions and 5 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: bitmap.c,v 1.32 2004/08/15 21:36:28 chorns Exp $
/* $Id: bitmap.c,v 1.33 2004/10/05 22:08:56 gvg Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c
@ -180,7 +180,8 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
IconDIR = MapViewOfFile(hSection, FILE_MAP_READ, 0, 0, 0);
CloseHandle(hSection);
if (IconDIR == NULL)
if (IconDIR == NULL || 0 != IconDIR->idReserved
|| (IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
{
return NULL;
}
@ -377,7 +378,8 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
0,
0);
if (IconDIR == NULL)
if (IconDIR == NULL || 0 != IconDIR->idReserved
|| (IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
{
CloseHandle(hFile);
CloseHandle(hSection);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: icon.c,v 1.22 2004/08/15 21:36:29 chorns Exp $
/* $Id: icon.c,v 1.23 2004/10/05 22:08:56 gvg Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/icon.c
@ -569,7 +569,7 @@ LookupIconIdFromDirectoryEx(
GRPCURSORICONDIR *dir = (GRPCURSORICONDIR*)presbits;
UINT retVal = 0;
if (dir && !dir->idReserved && (dir->idType & 3))
if (dir && !dir->idReserved && (IMAGE_ICON == dir->idType || IMAGE_CURSOR == dir->idType))
{
GRPCURSORICONDIRENTRY *entry;
HDC hdc;