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

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