diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2018-12-04 12:31:37 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2019-01-16 15:47:09 +1300 |
commit | 06afde5c45b58dd20a366d3dcb85d7e6fd702096 (patch) | |
tree | 9ed6e7b6b620d57a3924b0f5f3eac03683eeba63 | |
parent | fb32a04b61029c5e0a151c04095f1608195656c3 (diff) | |
download | gdk-pixbuf-06afde5c45b58dd20a366d3dcb85d7e6fd702096.tar.gz |
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.
-rw-r--r-- | gdk-pixbuf/io-gif.c | 2 | ||||
-rw-r--r-- | 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 |