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

bz3_compress crash on img0.jpg file #120

Closed
mrfearless opened this issue Dec 19, 2023 · 2 comments
Closed

bz3_compress crash on img0.jpg file #120

mrfearless opened this issue Dec 19, 2023 · 2 comments

Comments

@mrfearless
Copy link

Found a file that causes bz3_compress to crash. I have tried setting block size to 1MB, 65K, and the size of the file to see if that would change the result, even set the allocated memory to the bz3_bound value x2 to see if that helps also. In all cases it seems to still cause a crash.

I am attaching the img0.jpg file (stored in a zip) that is causing this issue.

Maybe its an edge case where the size of the file to be compressed is larger than the estimated bounds size for allocating memory? since its a jpeg and is compressed already. Anyhow just thought it was worth mentioning. Hopefully it can be confirmed that this file is causing a crash. Thanks in advance.

img0.zip

@kspalaiologos
Copy link
Owner

It is an edge case and weird logic in bz3_compress, which does not fudge the argument with bz3_bound to make sure that it stays in bounds:

https://github.com/kspalaiologos/bzip3/blob/master/src/libbz3.c#L807C1-L807C47

kspalaiologos added a commit that referenced this issue Dec 20, 2023
@mrfearless
Copy link
Author

mrfearless commented Dec 20, 2023

Thank you. I tested it with your fix and can confirm it is now compressing without any issues. Much appreciated, thanks again.

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

2 participants