summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-09-07 16:12:27 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-09-22 15:12:38 -0700
commitb4031fc023816aca07fbd592ed97010b9b48784b (patch)
tree968bbe840d0de799adccede44b65e5523391138e
parent73a37d5f2fcadd6540159b432a70d80f442ddf4a (diff)
XCreatePixmap: trigger BadValue error for out-of-range dimensions
The CreatePixmap request specifies height & width of the image as CARD16 (unsigned 16-bit integer), so if either is larger than that, set it to 0 so the X server returns a BadValue error as the protocol requires. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/CrPixmap.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/CrPixmap.c b/src/CrPixmap.c
index cdf31207..3cb2ca6d 100644
--- a/src/CrPixmap.c
+++ b/src/CrPixmap.c
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
+#include <limits.h>
#ifdef USE_DYNAMIC_XCURSOR
void
@@ -47,6 +48,16 @@ Pixmap XCreatePixmap (
Pixmap pid;
register xCreatePixmapReq *req;
+ /*
+ * Force a BadValue X Error if the requested dimensions are larger
+ * than the X11 protocol has room for, since that's how callers expect
+ * to get notified of errors.
+ */
+ if (width > USHRT_MAX)
+ width = 0;
+ if (height > USHRT_MAX)
+ height = 0;
+
LockDisplay(dpy);
GetReq(CreatePixmap, req);
req->drawable = d;