Add a deflate distance-code-31 test

This commit is contained in:
Nigel Tao committed 2019-02-02 13:04:09 +11:00
1 parent e9709992e2
commit 11a6819be9
8 files changed
+72 -2

No files matched your search

View File
Whitespace-only changes.
@@ -19,9 +19,7 @@ so the overall decoding is "abcdcdc".
000009 0x0009 . 0x03 0b_...._.011 Fixed Huffman block, final
000009 0x0009 . 0x03 0b_0000_0... lcode: 257 length: 3
000010 0x000A B 0x42 0b_...._..10
000010 0x000A B 0x42 0b_.100_00.. dcode: 1 distance: 2
000010 0x000A B 0x42 0b_0..._.... lcode: 256 end of block
000011 0x000B . 0x00 0b_..00_0000
@@ -0,0 +1 @@
~
@@ -0,0 +1,8 @@
Running deflate-distance-code-31.deflate through script/print-bits.go and
adding commentary:
offset xoffset ASCII hex binary
000000 0x0000 . 0x03 0b_...._.011 Fixed Huffman block, final
000000 0x0000 . 0x03 0b_0000_0... lcode: 257 length: 3
000001 0x0001 ~ 0x7E 0b_...._..10
000001 0x0001 ~ 0x7E 0b_.111_11.. dcode: 31 INVALID
@@ -0,0 +1,19 @@
# Feed this file to script/make-artificial.go
make deflate
# RFC 1951 section 3.2.6 says that for fixed Huffman codes, "distance codes
# 30-31 will never actually occur in the compressed data", and likewise for
# literal/length values 286-287.
#
# This dates from a more innocent time, before widespread concerns about
# malicious actors deliberately supplying invalid input to probe for security
# vulnerabilities. Upon encountering such input, a robust decoder shouldn't
# enter an internally inconsistent state.
#
# In terms of the Wuffs implementation (and error message convention), we
# should return an error, as it is indeed invalid input, but we shouldn't
# return an "internal error".
blockFixedHuffman (final) {
len 3 distCode 31
}