Jerome Leclanche : gdi32: Properly set ERROR_NOACCESS when GetObject receives invalid arguments.
Alexandre Julliard
julliard at winehq.org
Tue Oct 5 14:41:48 CDT 2010
Module: wine
Branch: stable
Commit: d429664016e69310930b7b15fa9c0705cb560da3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d429664016e69310930b7b15fa9c0705cb560da3
Author: Jerome Leclanche <adys.wh at gmail.com>
Date: Thu Aug 19 14:30:49 2010 +0100
gdi32: Properly set ERROR_NOACCESS when GetObject receives invalid arguments.
(cherry picked from commit da40f95efa58534d6f59dff11f8c9dbbbbb68520)
---
dlls/gdi32/gdiobj.c | 14 ++++++++++++--
dlls/gdi32/tests/gdiobj.c | 8 ++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c
index 3f84f9c..a941e2b 100644
--- a/dlls/gdi32/gdiobj.c
+++ b/dlls/gdi32/gdiobj.c
@@ -973,7 +973,12 @@ INT WINAPI GetObjectA( HGDIOBJ handle, INT count, LPVOID buffer )
GDI_ReleaseObj( handle );
if (funcs && funcs->pGetObjectA)
- result = funcs->pGetObjectA( handle, count, buffer );
+ {
+ if (buffer && ((ULONG_PTR)buffer >> 16) == 0) /* catch apps getting argument order wrong */
+ SetLastError( ERROR_NOACCESS );
+ else
+ result = funcs->pGetObjectA( handle, count, buffer );
+ }
else
SetLastError( ERROR_INVALID_HANDLE );
@@ -995,7 +1000,12 @@ INT WINAPI GetObjectW( HGDIOBJ handle, INT count, LPVOID buffer )
GDI_ReleaseObj( handle );
if (funcs && funcs->pGetObjectW)
- result = funcs->pGetObjectW( handle, count, buffer );
+ {
+ if (buffer && ((ULONG_PTR)buffer >> 16) == 0) /* catch apps getting argument order wrong */
+ SetLastError( ERROR_NOACCESS );
+ else
+ result = funcs->pGetObjectW( handle, count, buffer );
+ }
else
SetLastError( ERROR_INVALID_HANDLE );
diff --git a/dlls/gdi32/tests/gdiobj.c b/dlls/gdi32/tests/gdiobj.c
index c1adc0f..7302134 100644
--- a/dlls/gdi32/tests/gdiobj.c
+++ b/dlls/gdi32/tests/gdiobj.c
@@ -81,6 +81,14 @@ static void test_gdi_objects(void)
"GetObject(NULL obj), expected 0, NO_ERROR, got %d, %u\n",
i, GetLastError());
+ /* GetObject expects ERROR_NOACCESS when passed an invalid buffer */
+ hp = SelectObject(hdc, GetStockObject(BLACK_PEN));
+ SetLastError(0);
+ i = GetObjectA(hp, (INT_PTR)buff, (LPVOID)sizeof(buff));
+ ok (!i && GetLastError() == ERROR_NOACCESS,
+ "GetObject(invalid buff), expected 0, ERROR_NOACCESS, got %d, %u\n",
+ i, GetLastError());
+
/* GetObjectType does SetLastError() on a null object */
SetLastError(0);
i = GetObjectType(NULL);
More information about the wine-cvs
mailing list