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

Fix gzip file size check #128

Open
vampirefrog opened this issue Oct 27, 2024 · 0 comments
Open

Fix gzip file size check #128

vampirefrog opened this issue Oct 27, 2024 · 0 comments

Comments

@vampirefrog
Copy link

vampirefrog commented Oct 27, 2024

if(loader->srcSize >= 2 && loader->srcData[0] == 31 && loader->srcData[1] == 139) // check for .gz file header

Smallest possible gzip file size, according to the spec, is 18 bytes (10 byte header + 8 byte footer). Smallest I've been able to generate is 20 bytes (echo -n "" | gzip | hd). I'd make this check for 18 bytes at least. Technically you should also check the flags field and check for the extra fields too, but I think the 18 bytes check is a decent bugfix, since it would fix the line:

loader->decSize = ReadLE32(&loader->srcData[loader->srcSize - 4]);

if the file was smaller than 4 bytes.

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