mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-01 04:27:59 +02:00
Xdmx: integer overflow in GetGLXFBConfigs()
numFBConfigs & numAttribs are CARD32s and need to be bounds checked before multiplying by structure sizes to come up with the total size to allocate, to avoid integer overflow leading to underallocation and writing data from the network past the end of the allocated buffer. Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
parent
c89bcd12f4
commit
5fbd8c45b4
1 changed files with 8 additions and 4 deletions
|
|
@ -279,7 +279,10 @@ GetGLXFBConfigs(Display * dpy, int glxMajorOpcode, int *nconfigs)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
attrs = (INT32 *) Xmalloc(2 * numAttribs * __GLX_SIZE_CARD32);
|
||||
if (numAttribs < (INT_MAX / (2 * __GLX_SIZE_CARD32)))
|
||||
attrs = Xmalloc(2 * numAttribs * __GLX_SIZE_CARD32);
|
||||
else
|
||||
attrs = NULL;
|
||||
if (!attrs) {
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
|
|
@ -287,15 +290,16 @@ GetGLXFBConfigs(Display * dpy, int glxMajorOpcode, int *nconfigs)
|
|||
}
|
||||
|
||||
/* Allocate memory for our config structure */
|
||||
config = (__GLXFBConfig *)
|
||||
Xmalloc(numFBConfigs * sizeof(__GLXFBConfig));
|
||||
if (numFBConfigs < (INT_MAX / sizeof(__GLXFBConfig)))
|
||||
config = Xcalloc(numFBConfigs, sizeof(__GLXFBConfig));
|
||||
else
|
||||
config = NULL;
|
||||
if (!config) {
|
||||
free(attrs);
|
||||
UnlockDisplay(dpy);
|
||||
SyncHandle();
|
||||
return NULL;
|
||||
}
|
||||
memset(config, 0, numFBConfigs * sizeof(__GLXFBConfig));
|
||||
fbconfigs = config;
|
||||
|
||||
/* Convert attribute list into our format */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue