Blame SOURCES/ghostscript-cope-with-negative-run-length.patch

9ea96f
From ab4d21b69bf0717ac93072d24b076681bdb9b3a4 Mon Sep 17 00:00:00 2001
9ea96f
From: Chris Liddell <chris.liddell@artifex.com>
9ea96f
Date: Wed, 19 Jun 2013 16:25:17 +0100
9ea96f
Subject: [PATCH] Bug 693934: CCITT Fax decode - cope with negative run length
9ea96f
9ea96f
In various places in the fax decode code we coped with the run length being
9ea96f
negative - in just a few we didn't.
9ea96f
9ea96f
We'll now cope gracefully with negative run lengths in places.
9ea96f
9ea96f
No cluster differences.
9ea96f
---
9ea96f
 base/scfd.c | 13 +++++++++++++
9ea96f
 1 file changed, 13 insertions(+)
9ea96f
9ea96f
diff --git a/base/scfd.c b/base/scfd.c
9ea96f
index 970c925..5f7f798 100644
9ea96f
--- a/base/scfd.c
9ea96f
+++ b/base/scfd.c
9ea96f
@@ -611,6 +611,7 @@ v0:	    skip_bits(1);
9ea96f
                     rlen, "[w2]", d2l, out0);
9ea96f
             /* rlen may be run2_pass, run_uncompressed, or */
9ea96f
             /* 0..countof(cf2_run_vertical)-1. */
9ea96f
+rlen_lt_zero:
9ea96f
             if (rlen < 0)
9ea96f
                 switch (rlen) {
9ea96f
                     case run2_pass:
9ea96f
@@ -726,6 +727,9 @@ v0:	    skip_bits(1);
9ea96f
         status = ERRC;
9ea96f
         goto out;
9ea96f
     }
9ea96f
+
9ea96f
+    if (rlen < 0) goto rlen_lt_zero;
9ea96f
+
9ea96f
     skip_data(rlen, hww);
9ea96f
     /* Handle the second half of a white-black horizontal code. */
9ea96f
   hwb:get_run(cf_black_decode, cfd_black_initial_bits, cfd_black_min_bits,
9ea96f
@@ -734,6 +738,9 @@ v0:	    skip_bits(1);
9ea96f
         status = ERRC;
9ea96f
         goto out;
9ea96f
     }
9ea96f
+
9ea96f
+    if (rlen < 0) goto rlen_lt_zero;
9ea96f
+
9ea96f
     invert_data(rlen, black_byte, goto hwb, ihwb);
9ea96f
     goto top;
9ea96f
   outww:ss->run_color = -2;
9ea96f
@@ -747,6 +754,9 @@ v0:	    skip_bits(1);
9ea96f
         status = ERRC;
9ea96f
         goto out;
9ea96f
     }
9ea96f
+
9ea96f
+    if (rlen < 0) goto rlen_lt_zero;
9ea96f
+
9ea96f
     invert_data(rlen, black_byte, goto hbb, ihbb);
9ea96f
     /* Handle the second half of a black-white horizontal code. */
9ea96f
   hbw:get_run(cf_white_decode, cfd_white_initial_bits, cfd_white_min_bits,
9ea96f
@@ -755,6 +765,9 @@ v0:	    skip_bits(1);
9ea96f
         status = ERRC;
9ea96f
         goto out;
9ea96f
     }
9ea96f
+
9ea96f
+    if (rlen < 0) goto rlen_lt_zero;
9ea96f
+
9ea96f
     skip_data(rlen, hbw);
9ea96f
     goto top;
9ea96f
   outbb:ss->run_color = 2;
9ea96f
-- 
9ea96f
2.9.4
9ea96f