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

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