From 186982901a3b2868c3a6e32929b2eea52360c624 Mon Sep 17 00:00:00 2001 From: matthieu Date: Sat, 14 Oct 2017 09:33:48 +0000 Subject: [PATCH] MFC: dbe: Unvalidated variable-length request in ProcDbeGetVisualInfo (CVE-2017-12177) v2: Protect against integer overflow (Alan Coopersmith) --- xserver/dbe/dbe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xserver/dbe/dbe.c b/xserver/dbe/dbe.c index 23f7e164d..f31766f31 100644 --- a/xserver/dbe/dbe.c +++ b/xserver/dbe/dbe.c @@ -574,6 +574,9 @@ ProcDbeGetVisualInfo(ClientPtr client) XdbeScreenVisualInfo *pScrVisInfo; REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq); + if (stuff->n > UINT32_MAX / sizeof(CARD32)) + return BadLength; + REQUEST_FIXED_SIZE(xDbeGetVisualInfoReq, stuff->n * sizeof(CARD32)); if (stuff->n > UINT32_MAX / sizeof(DrawablePtr)) return BadAlloc; @@ -924,7 +927,7 @@ SProcDbeSwapBuffers(ClientPtr client) swapl(&stuff->n); if (stuff->n > UINT32_MAX / sizeof(DbeSwapInfoRec)) - return BadAlloc; + return BadLength; REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, stuff->n * sizeof(xDbeSwapInfo)); if (stuff->n != 0) {