Skip to content

Commit 6d5a093

Browse files
tkreuzerDarkFire01
authored andcommitted
[WIN32K:ENG] Relax surface parameter validation
If no bitmap buffer size is provided (e.g. allocation path from EngCreateBitmap), do not validate that the size calculation is valid. Should fix some display drivers, like Radeon IGP 320M. See CORE-13036, CORE-11676
1 parent 1e64d68 commit 6d5a093

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

win32ss/gdi/eng/surface.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,17 @@ SURFACE_AllocSurface(
157157
/* Is this an uncompressed format? */
158158
if (iFormat <= BMF_32BPP)
159159
{
160-
/* Calculate the correct bitmap size in bytes */
161-
if (!NT_SUCCESS(RtlULongMult(cjWidth, cy, &cjBits)))
162-
{
163-
DPRINT1("Overflow calculating size: cjWidth %lu, cy %lu\n",
164-
cjWidth, cy);
165-
return NULL;
166-
}
167-
168160
/* Did we get a buffer and size? */
169161
if ((pvBits != NULL) && (cjBufSize != 0))
170162
{
163+
/* Calculate and validate the bitmap size in bytes */
164+
if (!NT_SUCCESS(RtlULongMult(cjWidth, cy, &cjBits)))
165+
{
166+
DPRINT1("Overflow calculating size: cjWidth %lu, cy %lu\n",
167+
cjWidth, cy);
168+
return NULL;
169+
}
170+
171171
/* Make sure the buffer is large enough */
172172
if (cjBufSize < cjBits)
173173
{
@@ -176,6 +176,13 @@ SURFACE_AllocSurface(
176176
return NULL;
177177
}
178178
}
179+
else
180+
{
181+
/* Do a dumb calculation. Windows doesn't validate this either and
182+
some drivers (e.g. Radeon IGP 320M) eplicitly pass bogus values.
183+
See CORE-13036. */
184+
cjBits = cjWidth * cy;
185+
}
179186
}
180187
else
181188
{

0 commit comments

Comments
 (0)