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

Option to disable "raw" libarchive format #77

Open
asiekierka opened this issue Jan 25, 2022 · 7 comments
Open

Option to disable "raw" libarchive format #77

asiekierka opened this issue Jan 25, 2022 · 7 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@asiekierka
Copy link

I'd like to use compress-tools-rs in a situation where I want to treat archive and non-archive files differently; enabling the "raw" format makes it effectively impossible to distinguish archives from non-archives and/or corrupt archives.

@otavio
Copy link
Member

otavio commented Jan 26, 2022

I didn't understand the use case you're trying to cover. If you want to check if the file is an archive or not it might be done using the file header for example.

@asiekierka
Copy link
Author

The use-case is a tool which performs file analysis and searches on a directory, including support for traversing archive files found within said directory. The question I'm trying to answer, as such, is "is libarchive capable of parsing a given, otherwise unknown, file as an archive?".

Checking if a file is a valid archive with another tool is not sufficient, as (a) libarchive's scope of supported can depend on version and compile flags, (b) I would need to repeat myself by writing checks for every format currently supported by libarchive regardless.

@otavio
Copy link
Member

otavio commented Jan 26, 2022

Generally speaking, if not supported, it will report an error. Isn't this enough?

@asiekierka
Copy link
Author

asiekierka commented Jan 26, 2022

It will not. The "raw" format enables reading any file, even one which is not an archive, as an archive containing a single file, "data". Quoting from the libarchive documentation, emphasis mine:

archive_read_support_format_raw()
The “raw” format handler allows libarchive to be used to read arbitrary data. It treats any data stream as an archive with a single entry. The pathname of this entry is “data”; all other entry fields are unset. This is not enabled by archive_read_support_format_all() in order to avoid erroneous handling of damaged archives.

@otavio
Copy link
Member

otavio commented Jan 26, 2022

Ok so what is your proposal? Please open a draft PR proposing what you'd like to be done so we can understand it better.

@otavio
Copy link
Member

otavio commented Jul 24, 2022

Have you thought about the API you'd like to have?

@asiekierka
Copy link
Author

asiekierka commented Jul 24, 2022

Sorry. I've started looking into it, but I've been working on other projects since, and I have no ETA to coming back to this :(

@otavio otavio added the question Further information is requested label Oct 26, 2022
@otavio otavio added the help wanted Extra attention is needed label Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Development

No branches or pull requests

2 participants