简体   繁体   English

zlib inflate方法无法按预期工作

[英]zlib inflate method not working as expected

This is the code being used to inflate: 这是用于膨胀的代码:

z_ret = inflate(&oStream, Z_SYNC_FLUSH); 

z_ret returns Z_DATA_ERROR every time except for the first time in incoming stream z_ret返回Z_DATA_ERROR每次除了在输入数据流的第一次

As per the zlib webpage: 根据zlib网页:

Z_DATA_ERROR indicates that inflate() detected an error in the zlib compressed data format, which means that either the data is not a zlib stream to begin with, or that the data was corrupted somewhere along the way since it was compressed. Z_DATA_ERROR表示Z_DATA_ERROR inflate()检测到zlib压缩数据格式中的错误,这意味着数据不是开头的zlib流,或者数据在压缩后的某个地方已损坏。

Alternatively, it's possible that the data was compressed with a specific deflate dictionary, which zlib will need in order to inflate. 或者,可能是使用特定的deflate字典压缩数据,zlib需要这些字典才能进行充气。 If this is the case, the according to the link I mentioned: 如果是这种情况,根据我提到的链接:

... we have no idea what the dictionary is, so the Z_NEED_DICT indication is converted to a Z_DATA_ERROR . ...我们不知道字典是什么,所以Z_NEED_DICT指示被转换为Z_DATA_ERROR

I've not used zlib much myself, but this hints that you either have corrupt data, or not enough information to be able to decompress. 我自己并没有太多使用过zlib,但是这暗示你要么有破坏的数据,要么没有足够的信息来解压缩。


Edit : Having looked at Salsa's comment, and examining your code more, it's not clear that this is the actual issue. 编辑 :看过Salsa的评论,并更多地检查您的代码,目前尚不清楚这是否是实际问题。 You don't state what value z_ret has when inflate fails. inflate失败时,您没有说明z_ret值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM