Fix out-of-range comparison in _XF86BigfontQueryFont

clang complained (correctly):
warning: comparison of constant 768614336404564650 with expression
of type 'CARD32' (aka 'unsigned int') is always true
[-Wtautological-constant-out-of-range-compare]

[While LONG_MAX is correct, since it's used in size_t math, the
 numbers have to be limited to 32-bit range to be usable by 32-bit
 clients, and values beyond that range are far more likely to be
 bugs in the data from the server than valid numbers of characters
 in a font.   -alan- ]

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
Thomas Klausner 2013-06-25 18:34:32 +02:00 committed by Alan Coopersmith
parent 383e2b0d02
commit 6d926088d8

View file

@ -588,7 +588,7 @@ _XF86BigfontQueryFont (
if (!(extcodes->serverCapabilities & CAP_VerifiedLocal)) {
struct shmid_ds buf;
if (!(shmctl(reply.shmid, IPC_STAT, &buf) >= 0
&& reply.nCharInfos < (LONG_MAX / sizeof(XCharStruct))
&& reply.nCharInfos < (INT_MAX / sizeof(XCharStruct))
&& buf.shm_segsz >= reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct) + sizeof(CARD32)
&& *(CARD32 *)(addr + reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct)) == extcodes->serverSignature)) {
shmdt(addr);