[gdk-pixbuf: 2/7] gif: Fix off by one error in LZW decoder



commit 06afde5c45b58dd20a366d3dcb85d7e6fd702096
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Dec 4 12:31:37 2018 +1300

    gif: Fix off by one error in LZW decoder
    
    The following was occurring:
    1. Code words would be read from the LZW data blocks.
    2. If there was exactly enough space for one more codeword in the block, more
       blocks were read. This is the off by one error. It should have read the
       last code before doing this.
    3. If the next block was the terminating block the code would be marked as
       complete.
    4. Another block would be attempted to be read, because the decoder was still
       in the same state as step 2.
    5. An error was generated because the decoder was trying to read blocks after it
       had determined the stream had ended.
    
    This fixes the GIF decoder failing to decode images without an
    end-of-information code.

 gdk-pixbuf/io-gif.c                    | 2 +-
 tests/test-images/gif-test-suite/TESTS | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c
index 688cad542..3986635bc 100644
--- a/gdk-pixbuf/io-gif.c
+++ b/gdk-pixbuf/io-gif.c
@@ -540,7 +540,7 @@ get_code (GifContext *context,
 {
        int i, j, ret;
 
-       if ((context->code_curbit + code_size) >= context->code_lastbit){
+       if ((context->code_curbit + code_size) > context->code_lastbit){
                gif_set_lzw_fill_buffer (context);
                return -3;
        }
diff --git a/tests/test-images/gif-test-suite/TESTS b/tests/test-images/gif-test-suite/TESTS
index 2dfc87aee..cc986661e 100644
--- a/tests/test-images/gif-test-suite/TESTS
+++ b/tests/test-images/gif-test-suite/TESTS
@@ -31,8 +31,8 @@ missing-pixels
 extra-pixels
 extra-data
 no-clear
-#no-eoi
-#no-clear-and-eoi
+no-eoi
+no-clear-and-eoi
 #many-clears
 #double-clears
 invalid-colors


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]