1665N/AFrom 8ea762f94f4c942d898fdeb590a1630c83235c17 Mon Sep 17 00:00:00 2001
1665N/AFrom: Tobias Stoeckmann <tobias@stoeckmann.org>
1665N/ADate: Sun, 25 Sep 2016 21:25:25 +0200
1665N/ASubject: [PATCH:libX11] Validation of server responses in XGetImage()
1665N/ACheck if enough bytes were received for specified image type and
1665N/Ageometry. Otherwise GetPixel and other functions could trigger an
1665N/Aout of boundary read later on.
1665N/ASigned-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
1665N/AReviewed-by: Matthieu Herrb <matthieu@herrb.eu>
1665N/A 1 file changed, 20 insertions(+), 9 deletions(-)
1665N/A@@ -59,6 +59,7 @@ XImage *XGetImage (
1665N/A@@ -91,18 +92,28 @@ XImage *XGetImage (
1665N/A _XReadPad (dpy, data, nbytes);
1665N/A- format, 0, data, width, height, dpy->bitmap_pad, 0);
1665N/A- else /* format == ZPixmap */
1665N/A+ format, 0, data, width, height, dpy->bitmap_pad, 0);
1665N/A+ } else { /* format == ZPixmap */
1665N/A+ if (planes < 1 || image->height < 1 || image->bytes_per_line < 1 ||
1665N/A+ INT_MAX / image->height <= image->bytes_per_line ||
1665N/A+ INT_MAX / planes <= image->height * image->bytes_per_line ||
1665N/A+ nbytes < planes * image->height * image->bytes_per_line) {