Re: [ros-dev] [ros-diffs] [jgardou] 66342: [WIN32SS/NTGDI] - Reject bits data early in SetBitmapBits when it's clear that they can't fit in the destination bitmap. Fixes ugly Office 2007 rulers showin
Is this a bug in Office 2007 or are we doing something wrong here? Am 17.02.2015 um 21:41 schrieb jgar...@svn.reactos.org: Author: jgardou Date: Tue Feb 17 20:41:51 2015 New Revision: 66342 URL: http://svn.reactos.org/svn/reactos?rev=66342view=rev Log: [WIN32SS/NTGDI] - Reject bits data early in SetBitmapBits when it's clear that they can't fit in the destination bitmap. Fixes ugly Office 2007 rulers showing garbage. Modified: trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c Modified: trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c?rev=66342r1=66341r2=66342view=diff == --- trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c [iso-8859-1] Tue Feb 17 20:41:51 2015 @@ -11,7 +11,8 @@ #define NDEBUG #include debug.h -void +static +int NTAPI UnsafeSetBitmapBits( PSURFACE psurf, @@ -32,6 +33,9 @@ lDeltaDst = psurf-SurfObj.lDelta; lDeltaSrc = WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel); +if (cjBits (cjBits (lDeltaSrc * nHeight))) +return 0; + while (nHeight--) { /* Copy one line */ @@ -40,6 +44,7 @@ pjDst += lDeltaDst; } +return 1; } HBITMAP @@ -538,9 +543,8 @@ _SEH2_TRY { -ProbeForRead(pUnsafeBits, Bytes, 1); -UnsafeSetBitmapBits(psurf, Bytes, pUnsafeBits); -ret = 1; +ProbeForRead(pUnsafeBits, Bytes, sizeof(WORD)); +ret = UnsafeSetBitmapBits(psurf, Bytes, pUnsafeBits); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { smime.p7s Description: S/MIME Cryptographic Signature ___ Ros-dev mailing list Ros-dev@reactos.org http://www.reactos.org/mailman/listinfo/ros-dev
Re: [ros-dev] [ros-diffs] [jgardou] 66342: [WIN32SS/NTGDI] - Reject bits data early in SetBitmapBits when it's clear that they can't fit in the destination bitmap. Fixes ugly Office 2007 rulers showin
I don't really see what we could be doing wrong here. We're not responsible for the data an application passes to us. If we're not capable of correctly giving back the tuple (width,height, bpp) which permits to calculate the buffer size, we'd better stop everything and start thinking about raising goats in Greenland. Le 18/02/2015 09:40, Timo Kreuzer a écrit : Is this a bug in Office 2007 or are we doing something wrong here? Am 17.02.2015 um 21:41 schrieb jgar...@svn.reactos.org: Author: jgardou Date: Tue Feb 17 20:41:51 2015 New Revision: 66342 URL: http://svn.reactos.org/svn/reactos?rev=66342view=rev Log: [WIN32SS/NTGDI] - Reject bits data early in SetBitmapBits when it's clear that they can't fit in the destination bitmap. Fixes ugly Office 2007 rulers showing garbage. Modified: trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c Modified: trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c?rev=66342r1=66341r2=66342view=diff == --- trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c[iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c[iso-8859-1] Tue Feb 17 20:41:51 2015 @@ -11,7 +11,8 @@ #define NDEBUG #include debug.h -void +static +int NTAPI UnsafeSetBitmapBits( PSURFACE psurf, @@ -32,6 +33,9 @@ lDeltaDst = psurf-SurfObj.lDelta; lDeltaSrc = WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel); +if (cjBits (cjBits (lDeltaSrc * nHeight))) +return 0; + while (nHeight--) { /* Copy one line */ @@ -40,6 +44,7 @@ pjDst += lDeltaDst; } +return 1; } HBITMAP @@ -538,9 +543,8 @@ _SEH2_TRY { -ProbeForRead(pUnsafeBits, Bytes, 1); -UnsafeSetBitmapBits(psurf, Bytes, pUnsafeBits); -ret = 1; +ProbeForRead(pUnsafeBits, Bytes, sizeof(WORD)); +ret = UnsafeSetBitmapBits(psurf, Bytes, pUnsafeBits); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ___ Ros-dev mailing list Ros-dev@reactos.org http://www.reactos.org/mailman/listinfo/ros-dev ___ Ros-dev mailing list Ros-dev@reactos.org http://www.reactos.org/mailman/listinfo/ros-dev