Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory stomp due to libdeflate_gdeflate_compress_bound returning too small of a value and libdeflate_gdeflate_compress ignoring the output limit #41

Open
elasota opened this issue Jun 3, 2024 · 1 comment

Comments

@elasota
Copy link

elasota commented Jun 3, 2024

While running some tests, GDeflateDemo crashed due to stack corruption. Upon testing, it turns out that this was due to libdeflate_gdeflate_compress writing more data than libdeflate_gdeflate_compress_bound indicated was the upper limit.

Reproduction steps:

  • Extract "gdeflatecrash.bin" from the attached file
  • Compile GDeflateDemo in debug mode so stack corruption checks are enabled
  • Run GDeflateDemo /compress gdeflatecrash.bin .

gdeflatecrash.zip

@elasota elasota closed this as completed Jun 3, 2024
@elasota elasota reopened this Jun 3, 2024
@elasota elasota changed the title libdeflate_gdeflate_compress_bound sometimes returns a value that is too small to store the compressed output Memory stomp due to libdeflate_gdeflate_compress_bound returning too small of a value and libdeflate_gdeflate_compress ignoring the output limit Jun 3, 2024
@elasota
Copy link
Author

elasota commented Jun 3, 2024

I guess this is actually a 2-part bug: libdeflate_gdeflate_compress_bound returns too small of a value, but libdeflate_gdeflate_compress is also supposed to fail safely if more output is written than is specified in the page buffer, which it sometimes does, but with this sample, it is stomping memory above the provided limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant