aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/plum/hpack/huffman.rb1
-rw-r--r--test/plum/hpack/test_huffman.rb7
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/plum/hpack/huffman.rb b/lib/plum/hpack/huffman.rb
index 2e44eba..2de8504 100644
--- a/lib/plum/hpack/huffman.rb
+++ b/lib/plum/hpack/huffman.rb
@@ -23,6 +23,7 @@ module Plum
bits.each_char do |cb|
buf << cb
if c = HUFFMAN_TABLE_INVERSED[buf]
+ raise HPACKError.new("huffman: EOS detected") if c == 256
out << c
buf = ""
end
diff --git a/test/plum/hpack/test_huffman.rb b/test/plum/hpack/test_huffman.rb
index 5fbda63..27c3411 100644
--- a/test/plum/hpack/test_huffman.rb
+++ b/test/plum/hpack/test_huffman.rb
@@ -26,4 +26,11 @@ class HPACKHuffmanTest < Minitest::Test
Plum::HPACK::Huffman.decode(encoded)
}
end
+
+ def test_eos_in_encoded
+ encoded = "\xff\xff\xff\xff" # \xff\xff\xff\xfc + padding
+ assert_raises(Plum::HPACKError) {
+ Plum::HPACK::Huffman.decode(encoded)
+ }
+ end
end