I'm using udp to communicate between server and client.
The server has the ability to compress packets if they are too long (Deflate).
Now the problem is that sometimes the packet is still too long, even after compression.
After some experimenting I found out that such truncated compressed data is still decompressable (until the point of truncation of course).

Now the question is:
Can the result of the decompression change except for truncation (for Deflate)?

有帮助吗?

解决方案

If your question is: "Can the decompression of a truncated deflate stream deliver something other than the truncation of the original uncompressed data?", then the answer is no. There cannot be a misinterpretation of a truncated code to mean some other code. The Huffman codes that make up a deflate stream are prefix codes, so if the last code in the stream is cut off in the middle of the bits of that code, then that code is simply not decoded. The prefix bits unambiguously indicate that the whole code is not there.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top