Repository navigation
Verify ZIP symlink data only after its bounds check in PureLib #6675
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // This file has been modified for WinGet. See src/PureLib/readme.md for the local changes. | ||
|
|
||
| // pure.h - C99 interface: | ||
|
|
||
| #ifndef PURE_H | ||
|
|
@@ -1658,10 +1660,6 @@ int pure_zip_meta( | |
| int error = pure_zip_diff_cdh_lfh(&cdh, &lfh); | ||
| if (error) return error; | ||
| } | ||
| { | ||
| int error = pure_zip_verify_symlink(&cdh, &lfh, buffer); | ||
| if (error) return error; | ||
| } | ||
| assert(lfh.length >= PURE_ZIP_LFH_MIN); | ||
| lfh_offset += lfh.length; | ||
| // File Data (compressed or uncompressed): | ||
|
|
@@ -1670,6 +1668,11 @@ int pure_zip_meta( | |
| } | ||
| lfh_offset += cdh.compressed_size; | ||
| if (lfh_offset > size) return PURE_E_ZIP_LFH_DATA_OVERFLOW; | ||
| // Verify symlink data only after checking that it is within the buffer: | ||
| { | ||
| int error = pure_zip_verify_symlink(&cdh, &lfh, buffer); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has anyone looked at submitting this as an official patch to the upstream?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question! Upstream hasn't been active since 2020, so I went with a local fix for now. |
||
| if (error) return error; | ||
| } | ||
| // Data Descriptor Record (optional): | ||
| if (lfh.general_purpose_bit_flag & (1 << 3)) { | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.