Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Fix a bug in deflate_medium where it didn't take into account the current window size #31

Merged
merged 1 commit into from
Apr 23, 2021

Conversation

zlatanov
Copy link

During tests for websocket compression in https://github.com/dotnet/runtime we found what we think is a bug. Sometimes the deflate produced payload, which couldn't be inflated later (see dotnet/runtime#50235 for examples).

After trying to debug what might be happening I noticed that deflate_medium has a constant defined:

#define MAX_DIST2  ((1 << MAX_WBITS) - MIN_LOOKAHEAD)

This seems absolutely fine when the deflate is being used with 15 window bits, but seems wrong with any other window size.
The error went away after replacing this with MAX_DIST(s) which is defined as:

#define MAX_DIST(s)  ((s)->w_size-MIN_LOOKAHEAD)

A minimal c++ repro can be found here dotnet/runtime#50235 (comment). Let me know if you need more information and I will be happy to provide it.

@jtkukunas
Copy link
Contributor

Good catch. Thanks!

@jtkukunas jtkukunas merged commit bf29715 into intel:master Apr 23, 2021
jtkukunas added a commit that referenced this pull request Apr 15, 2022
Fix a bug in deflate_medium where it didn't take into account the current window size
jtkukunas added a commit that referenced this pull request Apr 25, 2022
Fix a bug in deflate_medium where it didn't take into account the current window size
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants