CVE-2016-7944.patch revision 1665
6033N/AFrom 61c1039ee23a2d1de712843bed3480654d7ef42e Mon Sep 17 00:00:00 2001
6033N/AFrom: Tobias Stoeckmann <tobias@stoeckmann.org>
6033N/ADate: Sun, 25 Sep 2016 22:38:44 +0200
6033N/ASubject: [PATCH:libXfixes] Integer overflow on illegal server response
6033N/A
6033N/AThe 32 bit field "rep.length" is not checked for validity, which allows
6033N/Aan integer overflow on 32 bit systems.
6033N/A
6033N/AA malicious server could send INT_MAX as length, which gets multiplied
6033N/Aby the size of XRectangle. In that case the client won't read the whole
6033N/Adata from server, getting out of sync.
6033N/A
6033N/ASigned-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
6033N/AReviewed-by: Matthieu Herrb <matthieu@herrb.eu>
6033N/A---
6033N/A src/Region.c | 15 ++++++++++++---
6033N/A 1 file changed, 12 insertions(+), 3 deletions(-)
6033N/A
6033N/Adiff --git a/src/Region.c b/src/Region.c
6033N/Aindex cb0cf6e..59bcc1a 100644
6033N/A--- a/src/Region.c
6033N/A+++ b/src/Region.c
6033N/A@@ -23,6 +23,7 @@
6033N/A #ifdef HAVE_CONFIG_H
6033N/A #include <config.h>
6033N/A #endif
6033N/A+#include <limits.h>
6033N/A #include "Xfixesint.h"
6033N/A
6033N/A XserverRegion
@@ -333,9 +334,17 @@ XFixesFetchRegionAndBounds (Display *dpy,
bounds->y = rep.y;
bounds->width = rep.width;
bounds->height = rep.height;
- nbytes = (long) rep.length << 2;
- nrects = rep.length >> 1;
- rects = Xmalloc (nrects * sizeof (XRectangle));
+
+ if (rep.length < (INT_MAX >> 2)) {
+ nbytes = (long) rep.length << 2;
+ nrects = rep.length >> 1;
+ rects = Xmalloc (nrects * sizeof (XRectangle));
+ } else {
+ nbytes = 0;
+ nrects = 0;
+ rects = NULL;
+ }
+
if (!rects)
{
_XEatDataWords(dpy, rep.length);
--
2.7.4