-
Notifications
You must be signed in to change notification settings - Fork 168
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
Detect UStar tar archives #308
Detect UStar tar archives #308
Conversation
49cdaa5
to
c891806
Compare
UStar tar archives have a `magic` header field at byte offset 257 in each entry whose value begins with the string `ustar`. Identify them with the MIME type `application/x-tar`. Also add test cases for a number of UStar-compatible formats, created by GNU tar 1.29 (with `--format=<format-name>`): * `tar.gnu.tar` * `tar.oldgnu.tar` * `tar.posix.tar` * `tar.ustar.tar` as well as `tar.star.tar` (created by star 1.6) and, for completeness, `tar.v7-gnu.tar` (a v7 tar archive created by GNU tar 1.29). Fixes gabriel-vasile#307.
c891806
to
bc2b8c3
Compare
Codecov Report
@@ Coverage Diff @@
## master #308 +/- ##
=======================================
Coverage 94.96% 94.96%
=======================================
Files 3 3
Lines 159 159
=======================================
Hits 151 151
Misses 6 6
Partials 2 2 📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like fuzzing found a problem.
Good catch 🙂 There's now a more sensible bounds check in place - the UStar format detection is now only performed if the buffer is long enough to store a (512-byte) UStar header. I've kept the old 256-byte length check because that's still relevant for the v7 format detection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
…#9604) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/gabriel-vasile/mimetype](https://github.com/gabriel-vasile/mimetype) | indirect | patch | `v1.4.1` -> `v1.4.2` | --- ### ⚠ Dependency Lookup Warnings ⚠ Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>gabriel-vasile/mimetype</summary> ### [`v1.4.2`](https://github.com/gabriel-vasile/mimetype/releases/tag/v1.4.2) [Compare Source](https://github.com/gabriel-vasile/mimetype/compare/v1.4.1...v1.4.2) #### What's Changed - Improve mov detection; closes [#​302](https://github.com/gabriel-vasile/mimetype/issues/302) by [@​gabriel-vasile](https://github.com/gabriel-vasile) in [https://github.com/gabriel-vasile/mimetype/pull/304](https://github.com/gabriel-vasile/mimetype/pull/304) - \[codespell] Fix typos. by [@​mdosch](https://github.com/mdosch) in [https://github.com/gabriel-vasile/mimetype/pull/303](https://github.com/gabriel-vasile/mimetype/pull/303) - Detect UStar tar archives by [@​chrisnovakovic](https://github.com/chrisnovakovic) in [https://github.com/gabriel-vasile/mimetype/pull/308](https://github.com/gabriel-vasile/mimetype/pull/308) - add jxr support [#​155](https://github.com/gabriel-vasile/mimetype/issues/155) by [@​dijotmathews](https://github.com/dijotmathews) in [https://github.com/gabriel-vasile/mimetype/pull/312](https://github.com/gabriel-vasile/mimetype/pull/312) - Added support for JXS file format by [@​V-R-Dighe](https://github.com/V-R-Dighe) in [https://github.com/gabriel-vasile/mimetype/pull/319](https://github.com/gabriel-vasile/mimetype/pull/319) - Bump golang.org/x/net from 0.7.0 to 0.8.0 by [@​dependabot](https://github.com/dependabot) in [https://github.com/gabriel-vasile/mimetype/pull/367](https://github.com/gabriel-vasile/mimetype/pull/367) #### New Contributors - [@​mdosch](https://github.com/mdosch) made their first contribution in [https://github.com/gabriel-vasile/mimetype/pull/303](https://github.com/gabriel-vasile/mimetype/pull/303) - [@​chrisnovakovic](https://github.com/chrisnovakovic) made their first contribution in [https://github.com/gabriel-vasile/mimetype/pull/308](https://github.com/gabriel-vasile/mimetype/pull/308) - [@​dijotmathews](https://github.com/dijotmathews) made their first contribution in [https://github.com/gabriel-vasile/mimetype/pull/312](https://github.com/gabriel-vasile/mimetype/pull/312) - [@​V-R-Dighe](https://github.com/V-R-Dighe) made their first contribution in [https://github.com/gabriel-vasile/mimetype/pull/319](https://github.com/gabriel-vasile/mimetype/pull/319) **Full Changelog**: gabriel-vasile/mimetype@v1.4.1...v1.4.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 3am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNTQuMCIsInVwZGF0ZWRJblZlciI6IjM0LjE1NC4wIn0=-->
UStar tar archives have a
magic
header field at byte offset 257 in each entry whose value begins with the stringustar
. Identify them with the MIME typeapplication/x-tar
.Also add test cases for a number of UStar-compatible formats, created by GNU tar 1.29 (with
--format=<format-name>
):tar.gnu.tar
tar.oldgnu.tar
tar.posix.tar
tar.ustar.tar
as well as
tar.star.tar
(created by star 1.6) and, for completeness,tar.v7-gnu.tar
(a v7 tar archive created by GNU tar 1.29).Fixes #307.