Stiffstream / restinio

Cross-platform, efficient, customizable, and robust asynchronous HTTP(S)/WebSocket server C++ library with the right balance between performance and ease of use
Other
1.16k stars 93 forks source link

Fix zlip decompressing for some cases. #179

Closed horu closed 1 year ago

horu commented 1 year ago

Hi. zlib doc says inflate returns Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced (https://github.com/madler/zlib/blob/master/zlib.h#L503). It means we can finish decompressing and break the loop even we still have input data ( avail_in is not zero ). In other case we get infinite loop when decompressing is finished but input buffer is not empty.

Thank you.

eao197 commented 1 year ago

Hi! Thanks, I'll take a look at it a bit later today.

eao197 commented 1 year ago

@horu, may I ask, have you encountered a case of infinite loop during decompression in the wild?

horu commented 1 year ago

We have got infinite loop for our high load service when it receives invalid post requests. We have no examples now but we had some.

eao197 commented 1 year ago

Thanks for your PR. I'm working on the update for RESTinio and hope to release a version with the fix in a couple of days.