mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-02 01:28:24 +02:00
CVE-2007-6429: Don't spuriously reject <8bpp shm pixmaps.
Move size validation after depth validation, and only validate size if
the bpp of the pixmap format is > 8. If bpp < 8 then we're already
protected from overflow by the width and height checks.
(cherry picked from commit e9fa7c1c88)
This commit is contained in:
parent
22abea41ed
commit
514c622618
1 changed files with 20 additions and 16 deletions
36
Xext/shm.c
36
Xext/shm.c
|
|
@ -745,14 +745,6 @@ ProcPanoramiXShmCreatePixmap(
|
|||
}
|
||||
if (width > 32767 || height > 32767)
|
||||
return BadAlloc;
|
||||
size = PixmapBytePad(width, depth) * height;
|
||||
if (sizeof(size) == 4) {
|
||||
if (size < width * height)
|
||||
return BadAlloc;
|
||||
/* thankfully, offset is unsigned */
|
||||
if (stuff->offset + size < size)
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
if (stuff->depth != 1)
|
||||
{
|
||||
|
|
@ -763,7 +755,17 @@ ProcPanoramiXShmCreatePixmap(
|
|||
client->errorValue = stuff->depth;
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
CreatePmap:
|
||||
size = PixmapBytePad(width, depth) * height;
|
||||
if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
|
||||
if (size < width * height)
|
||||
return BadAlloc;
|
||||
/* thankfully, offset is unsigned */
|
||||
if (stuff->offset + size < size)
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
|
||||
|
||||
if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
|
||||
|
|
@ -1083,14 +1085,6 @@ ProcShmCreatePixmap(client)
|
|||
}
|
||||
if (width > 32767 || height > 32767)
|
||||
return BadAlloc;
|
||||
size = PixmapBytePad(width, depth) * height;
|
||||
if (sizeof(size) == 4) {
|
||||
if (size < width * height)
|
||||
return BadAlloc;
|
||||
/* thankfully, offset is unsigned */
|
||||
if (stuff->offset + size < size)
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
if (stuff->depth != 1)
|
||||
{
|
||||
|
|
@ -1101,7 +1095,17 @@ ProcShmCreatePixmap(client)
|
|||
client->errorValue = stuff->depth;
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
CreatePmap:
|
||||
size = PixmapBytePad(width, depth) * height;
|
||||
if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
|
||||
if (size < width * height)
|
||||
return BadAlloc;
|
||||
/* thankfully, offset is unsigned */
|
||||
if (stuff->offset + size < size)
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
|
||||
pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)(
|
||||
pDraw->pScreen, stuff->width,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue