- Fixed check for an out of range index in {Get/Set}{Class/Window}Long

(signed vs. unsigned arithmetic). Fixes crash in 'user32_test win'.

svn path=/trunk/; revision=8614
This commit is contained in:
David Welch 2004-03-09 21:21:39 +00:00
parent 860bde3b68
commit e04ce16d15
2 changed files with 6 additions and 6 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: class.c,v 1.48 2004/02/24 13:27:03 weiden Exp $
/* $Id: class.c,v 1.49 2004/03/09 21:21:39 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -433,7 +433,7 @@ IntGetClassLong(struct _WINDOW_OBJECT *WindowObject, ULONG Offset, BOOL Ansi)
if ((int)Offset >= 0)
{
DPRINT("GetClassLong(%x, %d)\n", WindowObject->Self, Offset);
if (Offset > WindowObject->Class->cbClsExtra - sizeof(LONG))
if ((Offset + sizeof(LONG)) > WindowObject->Class->cbClsExtra)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
@ -514,7 +514,7 @@ IntSetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, LONG dwNewLong, BOOL
if ((int)Offset >= 0)
{
DPRINT("SetClassLong(%x, %d, %x)\n", WindowObject->Self, Offset, dwNewLong);
if (Offset > WindowObject->Class->cbClsExtra - sizeof(LONG))
if ((Offset + sizeof(LONG)) > WindowObject->Class->cbClsExtra)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return;

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: window.c,v 1.197 2004/02/27 22:21:32 weiden Exp $
/* $Id: window.c,v 1.198 2004/03/09 21:21:39 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -2674,7 +2674,7 @@ NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi)
if ((INT)Index >= 0)
{
if (Index > WindowObject->ExtraDataSize - sizeof(LONG))
if ((Index + sizeof(LONG)) > WindowObject->ExtraDataSize)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
@ -2774,7 +2774,7 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
if ((INT)Index >= 0)
{
if (Index > WindowObject->ExtraDataSize - sizeof(LONG))
if ((Index + sizeof(LONG)) > WindowObject->ExtraDataSize)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
IntReleaseWindowObject(WindowObject);