Blame SOURCES/libtiff-CVE-2011-0192.patch

7c98bb
Protect against a fax VL(n) codeword commanding a move left.  Without
7c98bb
this, a malicious input file can generate an indefinitely large series
7c98bb
of runs without a0 ever reaching the right margin, thus overrunning
7c98bb
our buffer of run lengths.  Per CVE-2011-0192.  This is a modified
7c98bb
version of a patch proposed by Drew Yao of Apple Product Security.
7c98bb
It adds an unexpected() report, and disallows the equality case except
7c98bb
for the first run of a line, since emitting a run without increasing a0
7c98bb
still allows buffer overrun.  (We have to allow it for the first run to
7c98bb
cover the case of encoding a zero-length run at start of line using VL.)
7c98bb
7c98bb
7c98bb
diff -Naur tiff-3.9.4.orig/libtiff/tif_fax3.h tiff-3.9.4/libtiff/tif_fax3.h
7c98bb
--- tiff-3.9.4.orig/libtiff/tif_fax3.h	2010-06-08 14:50:42.000000000 -0400
7c98bb
+++ tiff-3.9.4/libtiff/tif_fax3.h	2011-03-10 12:11:20.850839162 -0500
7c98bb
@@ -478,6 +478,12 @@
7c98bb
 	    break;							\
7c98bb
 	case S_VL:							\
7c98bb
 	    CHECK_b1;							\
7c98bb
+	    if (b1 <= (int) (a0 + TabEnt->Param)) {			\
7c98bb
+		if (b1 < (int) (a0 + TabEnt->Param) || pa != thisrun) {	\
7c98bb
+		    unexpected("VL", a0);				\
7c98bb
+		    goto eol2d;						\
7c98bb
+		}							\
7c98bb
+	    }								\
7c98bb
 	    SETVALUE(b1 - a0 - TabEnt->Param);				\
7c98bb
 	    b1 -= *--pb;						\
7c98bb
 	    break;							\