Bug report: Deflate with some option is not working well for an empty input
- Dominant language
- JavaScript
- Stars
- 35.8k
- Forks
- 4.1k
- Avg merge
- 2d 26m
- Merged PRs (30d)
- 33
Description
**Describe the bug**
Following operations doesn't work well with an empty input:
* Raw Deflate
* Fixed Huffman Coding
* None (Store)
* Zlib Deflate
* Fixed Huffman Coding
* None (Store)
"None (Store)" in both operation produces very long (around 32768 bytes) output.
"Fixed Huffman Coding" in "Raw Deflate" produces 1-byte output `03`.
The results results in error when Inflated.
"Fixed Huffman Coding" in "Zlib Deflate" results in `78 5e 03 00 00 00 01`.
This yields an error when using "Zlib Inflate" with "Verify result" checked.
**To Reproduce**
* None (Store)
* [Raw Deflate - CyberChef](https://gchq.github.io/CyberChef/#recipe=Raw_Deflate%28%27None%20%28Store%29%27%29)
* [Zlib Deflate - CyberChef](https://gchq.github.io/CyberChef/#recipe=Zlib_Deflate%28%27None%20%28Store%29%27%29)
* Fixed Huffman Coding
* [Raw Deflate, To Hex - CyberChef](https://gchq.github.io/CyberChef/#recipe=Raw_Deflate%28%27Fixed%20Huffman%20Coding%27%29To_Hex%28%27Space%27,0%29)
* [Zlib Deflate, Zlib Inflate - CyberChef](https://gchq.github.io/CyberChef/#recipe=Zlib_Deflate%28%27Fixed%20Huffman%20Coding%27%29Zlib_Inflate%280,0,%27Adaptive%27,false,true%29)
**Expected behaviour**
Handles empty input properly.
* "Raw Deflate" with "None (Store)" should result in `01 00 00 ff ff`.
* "Zlib Deflate" with "None (Store)" should result in `01 01 00 00 ff ff 00 00 00 01`.
* "Raw Deflate" with "Fixed Huffman Coding" should result in `03 00`.
* "Zlib Deflate" with "Fixed Huffman Coding" should result in something like `78 5e 03 00 00 00 00 01`.
I referred [rfc1951](https://datatracker.ietf.org/doc/html/rfc1951) to make expected output for "Raw Deflate".
This output for "Zlib Deflate" with "None (Store)" is produced with with a Python code `zlib.compress(b'', level=0)`.
It looks like one `00` is missing from the output of "Zlib Deflate" with "Fixed Huffman Coding" like one of "Raw Deflate".
**Desktop (if relevant, please complete the following information):**
- OS: Windows 10 Home 20H2
- Browser: Firefox 94.0.1 (x64)
- CyberChef version: 9.32.3
**Additional context**
Information in "REPORT A BUG" tab:
* Version: 9.32.3
* Compile time: 03/09/2021 14:01:00 UTC
* User-Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0
* [Link to reproduce](https://gchq.github.io/CyberChef/#recipe=Raw_Deflate('Fixed%20Huffman%20Coding')Raw_Inflate(0,0,'Adaptive',false,false))
Contributor guide
Assessment
This issue has not been assessed yet.