Commit 0a05ba257b6ddd87dacf8d54b626e4b360e0a596

Werner Lemberg 2009-03-20T07:19:45

Protect against malformed compressed data. Problem reported by Tavis Ormandy <taviso@google.com>. * src/lsw/ftzopen.c (ft_lzwstate_io): Test whether `state->prefix' is zero.

diff --git a/ChangeLog b/ChangeLog
index 512d99c..f208f51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2009-03-20  Werner Lemberg  <wl@gnu.org>
 
+	Protect against malformed compressed data.
+
+	Problem reported by Tavis Ormandy <taviso@google.com>.
+
+	* src/lsw/ftzopen.c (ft_lzwstate_io): Test whether `state->prefix' is
+	zero.
+
+2009-03-20  Werner Lemberg  <wl@gnu.org>
+
 	Protect against invalid SID values in CFFs.
 
 	Problem reported by Tavis Ormandy <taviso@google.com>.
diff --git a/src/lzw/ftzopen.c b/src/lzw/ftzopen.c
index fc78315..c0483de 100644
--- a/src/lzw/ftzopen.c
+++ b/src/lzw/ftzopen.c
@@ -332,6 +332,9 @@
 
           while ( code >= 256U )
           {
+            if ( !state->prefix )
+              goto Eof;
+
             FTLZW_STACK_PUSH( state->suffix[code - 256] );
             code = state->prefix[code - 256];
           }