Commit c4e7705d authored by Reinhard Tartler's avatar Reinhard Tartler

Imported nxagent-3.2.0-7.tar.gz

Summary: Imported nxagent-3.2.0-7.tar.gz Keywords: Imported nxagent-3.2.0-7.tar.gz into Git repository
parent c9983230
ChangeLog: ChangeLog:
nxagent-3.2.0-7
- Imported patch fixing issues from X.Org security advisory, June
11th, 2008: Multiple vulnerabilities in X server extensions. CVE
IDs: CVE-2008-1377, CVE-2008-1379, CVE-2008-2360, CVE-2008-2361,
CVE-2008-2362.
nxagent-3.2.0-6 nxagent-3.2.0-6
- Fixed TR05F02063. Ignore ReparentNotify events for non-rootless - Fixed TR05F02063. Ignore ReparentNotify events for non-rootless
......
...@@ -69,6 +69,17 @@ ...@@ -69,6 +69,17 @@
#undef DEBUG #undef DEBUG
#undef TEST #undef TEST
#else
#include "picturestr.h"
#include "glyphstr.h"
#endif
#if HAVE_STDINT_H
#include <stdint.h>
#elif !defined(UINT32_MAX)
#define UINT32_MAX 0xffffffffU
#endif #endif
/* /*
...@@ -401,8 +412,12 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth) ...@@ -401,8 +412,12 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
{ {
int size; int size;
GlyphPtr glyph; GlyphPtr glyph;
size_t padded_width;
size = gi->height * PixmapBytePad (gi->width, glyphDepths[fdepth]);
padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]);
if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height)
return 0;
size = gi->height * padded_width;
glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec)); glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
if (!glyph) if (!glyph)
return 0; return 0;
......
...@@ -69,6 +69,17 @@ ...@@ -69,6 +69,17 @@
#undef DEBUG #undef DEBUG
#undef TEST #undef TEST
#else
#include "picturestr.h"
#include "glyphstr.h"
#endif
#if HAVE_STDINT_H
#include <stdint.h>
#elif !defined(UINT32_MAX)
#define UINT32_MAX 0xffffffffU
#endif #endif
/* /*
...@@ -401,8 +412,12 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth) ...@@ -401,8 +412,12 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
{ {
int size; int size;
GlyphPtr glyph; GlyphPtr glyph;
size_t padded_width;
size = gi->height * PixmapBytePad (gi->width, glyphDepths[fdepth]);
padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]);
if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height)
return 0;
size = gi->height * padded_width;
glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec)); glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
if (!glyph) if (!glyph)
return 0; return 0;
......
...@@ -43,6 +43,12 @@ ...@@ -43,6 +43,12 @@
#include "picturestr.h" #include "picturestr.h"
#include "glyphstr.h" #include "glyphstr.h"
#if HAVE_STDINT_H
#include <stdint.h>
#elif !defined(UINT32_MAX)
#define UINT32_MAX 0xffffffffU
#endif
/* /*
* From Knuth -- a good choice for hash/rehash values is p, p-2 where * From Knuth -- a good choice for hash/rehash values is p, p-2 where
* p and p-2 are both prime. These tables are sized to have an extra 10% * p and p-2 are both prime. These tables are sized to have an extra 10%
...@@ -334,8 +340,12 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth) ...@@ -334,8 +340,12 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
{ {
int size; int size;
GlyphPtr glyph; GlyphPtr glyph;
size_t padded_width;
size = gi->height * PixmapBytePad (gi->width, glyphDepths[fdepth]);
padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]);
if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height)
return 0;
size = gi->height * padded_width;
glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec)); glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
if (!glyph) if (!glyph)
return 0; return 0;
......
...@@ -1893,6 +1893,8 @@ ProcRenderCreateCursor (ClientPtr client) ...@@ -1893,6 +1893,8 @@ ProcRenderCreateCursor (ClientPtr client)
pScreen = pSrc->pDrawable->pScreen; pScreen = pSrc->pDrawable->pScreen;
width = pSrc->pDrawable->width; width = pSrc->pDrawable->width;
height = pSrc->pDrawable->height; height = pSrc->pDrawable->height;
if (height && width > UINT32_MAX/(height*sizeof(CARD32)))
return BadAlloc;
if ( stuff->x > width if ( stuff->x > width
|| stuff->y > height ) || stuff->y > height )
return (BadMatch); return (BadMatch);
...@@ -2353,6 +2355,8 @@ static int ProcRenderCreateLinearGradient (ClientPtr client) ...@@ -2353,6 +2355,8 @@ static int ProcRenderCreateLinearGradient (ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->pid, client); LEGAL_NEW_RESOURCE(stuff->pid, client);
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -2955,18 +2959,18 @@ SProcRenderCreateSolidFill(ClientPtr client) ...@@ -2955,18 +2959,18 @@ SProcRenderCreateSolidFill(ClientPtr client)
return (*ProcRenderVector[stuff->renderReqType]) (client); return (*ProcRenderVector[stuff->renderReqType]) (client);
} }
static void swapStops(void *stuff, int n) static void swapStops(void *stuff, int num)
{ {
int i; int i, n;
CARD32 *stops; CARD32 *stops;
CARD16 *colors; CARD16 *colors;
stops = (CARD32 *)(stuff); stops = (CARD32 *)(stuff);
for (i = 0; i < n; ++i) { for (i = 0; i < num; ++i) {
swapl(stops, n); swapl(stops, n);
++stops; ++stops;
} }
colors = (CARD16 *)(stops); colors = (CARD16 *)(stops);
for (i = 0; i < 4*n; ++i) { for (i = 0; i < 4*num; ++i) {
swaps(stops, n); swaps(stops, n);
++stops; ++stops;
} }
...@@ -2989,6 +2993,8 @@ SProcRenderCreateLinearGradient (ClientPtr client) ...@@ -2989,6 +2993,8 @@ SProcRenderCreateLinearGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -3016,6 +3022,8 @@ SProcRenderCreateRadialGradient (ClientPtr client) ...@@ -3016,6 +3022,8 @@ SProcRenderCreateRadialGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -3040,6 +3048,8 @@ SProcRenderCreateConicalGradient (ClientPtr client) ...@@ -3040,6 +3048,8 @@ SProcRenderCreateConicalGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
......
...@@ -1893,6 +1893,8 @@ ProcRenderCreateCursor (ClientPtr client) ...@@ -1893,6 +1893,8 @@ ProcRenderCreateCursor (ClientPtr client)
pScreen = pSrc->pDrawable->pScreen; pScreen = pSrc->pDrawable->pScreen;
width = pSrc->pDrawable->width; width = pSrc->pDrawable->width;
height = pSrc->pDrawable->height; height = pSrc->pDrawable->height;
if (height && width > UINT32_MAX/(height*sizeof(CARD32)))
return BadAlloc;
if ( stuff->x > width if ( stuff->x > width
|| stuff->y > height ) || stuff->y > height )
return (BadMatch); return (BadMatch);
...@@ -2353,6 +2355,8 @@ static int ProcRenderCreateLinearGradient (ClientPtr client) ...@@ -2353,6 +2355,8 @@ static int ProcRenderCreateLinearGradient (ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->pid, client); LEGAL_NEW_RESOURCE(stuff->pid, client);
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -2955,18 +2959,18 @@ SProcRenderCreateSolidFill(ClientPtr client) ...@@ -2955,18 +2959,18 @@ SProcRenderCreateSolidFill(ClientPtr client)
return (*ProcRenderVector[stuff->renderReqType]) (client); return (*ProcRenderVector[stuff->renderReqType]) (client);
} }
static void swapStops(void *stuff, int n) static void swapStops(void *stuff, int num)
{ {
int i; int i, n;
CARD32 *stops; CARD32 *stops;
CARD16 *colors; CARD16 *colors;
stops = (CARD32 *)(stuff); stops = (CARD32 *)(stuff);
for (i = 0; i < n; ++i) { for (i = 0; i < num; ++i) {
swapl(stops, n); swapl(stops, n);
++stops; ++stops;
} }
colors = (CARD16 *)(stops); colors = (CARD16 *)(stops);
for (i = 0; i < 4*n; ++i) { for (i = 0; i < 4*num; ++i) {
swaps(stops, n); swaps(stops, n);
++stops; ++stops;
} }
...@@ -2989,6 +2993,8 @@ SProcRenderCreateLinearGradient (ClientPtr client) ...@@ -2989,6 +2993,8 @@ SProcRenderCreateLinearGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -3016,6 +3022,8 @@ SProcRenderCreateRadialGradient (ClientPtr client) ...@@ -3016,6 +3022,8 @@ SProcRenderCreateRadialGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -3040,6 +3048,8 @@ SProcRenderCreateConicalGradient (ClientPtr client) ...@@ -3040,6 +3048,8 @@ SProcRenderCreateConicalGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
......
...@@ -1505,6 +1505,8 @@ ProcRenderCreateCursor (ClientPtr client) ...@@ -1505,6 +1505,8 @@ ProcRenderCreateCursor (ClientPtr client)
pScreen = pSrc->pDrawable->pScreen; pScreen = pSrc->pDrawable->pScreen;
width = pSrc->pDrawable->width; width = pSrc->pDrawable->width;
height = pSrc->pDrawable->height; height = pSrc->pDrawable->height;
if (height && width > UINT32_MAX/(height*sizeof(CARD32)))
return BadAlloc;
if ( stuff->x > width if ( stuff->x > width
|| stuff->y > height ) || stuff->y > height )
return (BadMatch); return (BadMatch);
...@@ -1918,6 +1920,8 @@ static int ProcRenderCreateLinearGradient (ClientPtr client) ...@@ -1918,6 +1920,8 @@ static int ProcRenderCreateLinearGradient (ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->pid, client); LEGAL_NEW_RESOURCE(stuff->pid, client);
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -2489,18 +2493,18 @@ SProcRenderCreateSolidFill(ClientPtr client) ...@@ -2489,18 +2493,18 @@ SProcRenderCreateSolidFill(ClientPtr client)
return (*ProcRenderVector[stuff->renderReqType]) (client); return (*ProcRenderVector[stuff->renderReqType]) (client);
} }
static void swapStops(void *stuff, int n) static void swapStops(void *stuff, int num)
{ {
int i; int i, n;
CARD32 *stops; CARD32 *stops;
CARD16 *colors; CARD16 *colors;
stops = (CARD32 *)(stuff); stops = (CARD32 *)(stuff);
for (i = 0; i < n; ++i) { for (i = 0; i < num; ++i) {
swapl(stops, n); swapl(stops, n);
++stops; ++stops;
} }
colors = (CARD16 *)(stops); colors = (CARD16 *)(stops);
for (i = 0; i < 4*n; ++i) { for (i = 0; i < 4*num; ++i) {
swaps(stops, n); swaps(stops, n);
++stops; ++stops;
} }
...@@ -2523,6 +2527,8 @@ SProcRenderCreateLinearGradient (ClientPtr client) ...@@ -2523,6 +2527,8 @@ SProcRenderCreateLinearGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -2550,6 +2556,8 @@ SProcRenderCreateRadialGradient (ClientPtr client) ...@@ -2550,6 +2556,8 @@ SProcRenderCreateRadialGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
...@@ -2574,6 +2582,8 @@ SProcRenderCreateConicalGradient (ClientPtr client) ...@@ -2574,6 +2582,8 @@ SProcRenderCreateConicalGradient (ClientPtr client)
swapl(&stuff->nStops, n); swapl(&stuff->nStops, n);
len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq); len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength; return BadLength;
......
...@@ -194,10 +194,6 @@ static DeleteType *DeleteFuncs = (DeleteType *)NULL; ...@@ -194,10 +194,6 @@ static DeleteType *DeleteFuncs = (DeleteType *)NULL;
Atom * ResourceNames = NULL; Atom * ResourceNames = NULL;
#ifdef NXAGENT_SERVER
static int nxagentResChangedFlag = 0;
#endif
void RegisterResourceName (RESTYPE type, char *name) void RegisterResourceName (RESTYPE type, char *name)
{ {
ResourceNames[type & TypeMask] = MakeAtom(name, strlen(name), TRUE); ResourceNames[type & TypeMask] = MakeAtom(name, strlen(name), TRUE);
...@@ -205,6 +201,10 @@ void RegisterResourceName (RESTYPE type, char *name) ...@@ -205,6 +201,10 @@ void RegisterResourceName (RESTYPE type, char *name)
#endif #endif
#ifdef NXAGENT_SERVER
static int nxagentResChangedFlag = 0;
#endif
RESTYPE RESTYPE
CreateNewResourceType(DeleteType deleteFunc) CreateNewResourceType(DeleteType deleteFunc)
{ {
......
...@@ -967,8 +967,17 @@ ProcShmPutImage(client) ...@@ -967,8 +967,17 @@ ProcShmPutImage(client)
return BadValue; return BadValue;
} }
VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight, /*
client); * There's a potential integer overflow in this check:
* VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight,
* client);
* the version below ought to avoid it
*/
if (stuff->totalHeight != 0 &&
length > (shmdesc->size - stuff->offset)/stuff->totalHeight) {
client->errorValue = stuff->totalWidth;
return BadValue;
}
if (stuff->srcX > stuff->totalWidth) if (stuff->srcX > stuff->totalWidth)
{ {
client->errorValue = stuff->srcX; client->errorValue = stuff->srcX;
......
...@@ -967,8 +967,17 @@ ProcShmPutImage(client) ...@@ -967,8 +967,17 @@ ProcShmPutImage(client)
return BadValue; return BadValue;
} }
VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight, /*
client); * There's a potential integer overflow in this check:
* VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight,
* client);
* the version below ought to avoid it
*/
if (stuff->totalHeight != 0 &&
length > (shmdesc->size - stuff->offset)/stuff->totalHeight) {
client->errorValue = stuff->totalWidth;
return BadValue;
}
if (stuff->srcX > stuff->totalWidth) if (stuff->srcX > stuff->totalWidth)
{ {
client->errorValue = stuff->srcX; client->errorValue = stuff->srcX;
......
...@@ -863,8 +863,17 @@ ProcShmPutImage(client) ...@@ -863,8 +863,17 @@ ProcShmPutImage(client)
return BadValue; return BadValue;
} }
VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight, /*
client); * There's a potential integer overflow in this check:
* VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight,
* client);
* the version below ought to avoid it
*/
if (stuff->totalHeight != 0 &&
length > (shmdesc->size - stuff->offset)/stuff->totalHeight) {
client->errorValue = stuff->totalWidth;
return BadValue;
}
if (stuff->srcX > stuff->totalWidth) if (stuff->srcX > stuff->totalWidth)
{ {
client->errorValue = stuff->srcX; client->errorValue = stuff->srcX;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment