summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-09-07 15:55:04 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-09-22 15:12:38 -0700
commit73a37d5f2fcadd6540159b432a70d80f442ddf4a (patch)
treef3677a7d41668c2df5fd44f43db0538e6f97c437
parent204c3393c4c90a29ed6bef64e43849536e863a86 (diff)
XPutImage: clip images to maximum height & width allowed by protocol
The PutImage request specifies height & width of the image as CARD16 (unsigned 16-bit integer), same as the maximum dimensions of an X11 Drawable, which the image is being copied to. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/PutImage.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/PutImage.c b/src/PutImage.c
index a6db7b42..ba411e36 100644
--- a/src/PutImage.c
+++ b/src/PutImage.c
@@ -30,6 +30,7 @@ in this Software without prior written authorization from The Open Group.
#include "Xlibint.h"
#include "Xutil.h"
#include <stdio.h>
+#include <limits.h>
#include "Cr.h"
#include "ImUtil.h"
#include "reallocarray.h"
@@ -962,6 +963,10 @@ XPutImage (
height = image->height - req_yoffset;
if ((width <= 0) || (height <= 0))
return 0;
+ if (width > USHRT_MAX)
+ width = USHRT_MAX;
+ if (height > USHRT_MAX)
+ height = USHRT_MAX;
if ((image->bits_per_pixel == 1) || (image->format != ZPixmap)) {
dest_bits_per_pixel = 1;