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

Report unsupported compression in solv_xfopen() with errno #563

Merged
merged 1 commit into from
May 16, 2024

Conversation

ppisar
Copy link
Contributor

@ppisar ppisar commented May 13, 2024

If libsolv was built without Zstandard support and "primary.xml.zst" was passed solv_xfopen(), solv_xfopen() returned 0 without setting errno. A calling application could not distinguish an unsupported compression format from other I/O errors.

This patch improves this situation by setting errno variable to an appropriate value.

@mlschroe
Copy link
Member

Is ENOTSUP available everywhere? I.e. on BSD and windows (MSVC)?

(You can also use solv_xfopen_iscompressed() to figure out if the compression is supported: it returns 0 if the file is not compressed, 1 if it is compressed and the compression is supported, or -1 if the compression is not supported.)

@ppisar
Copy link
Contributor Author

ppisar commented May 14, 2024

I have no idea. Do people process YUM repositories on BSD or Windows?

@ppisar
Copy link
Contributor Author

ppisar commented May 14, 2024

ENOTSUP is documented in POSIX 2017 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html.

@Conan-Kudo
Copy link
Member

I have no idea. Do people process YUM repositories on BSD or Windows?

Yes. But also this is not YUM-only.

@ppisar
Copy link
Contributor Author

ppisar commented May 14, 2024

Ok. I will add a #ifdef guard.

@ppisar ppisar force-pushed the solv_xfopen_unsupported_error branch from 84e3503 to 7a80f35 Compare May 14, 2024 12:39
@ppisar
Copy link
Contributor Author

ppisar commented May 14, 2024

Now the code should compile even if ENOTSUP is not available.

@mlschroe
Copy link
Member

I think if it's in POSIX we don't need the guard. If somebody complains that it's missing for some specific OS, we can add a

#ifndef ENOTSUP
#define ENOTSUP <something_else>
#endif

at the beginning...

If libsolv was built without Zstandard support and "primary.xml.zst"
was passed solv_xfopen(), solv_xfopen() returned 0 without setting
errno. A calling application could not distinguish an unsupported
compression format from other I/O errors.

This patch improves this situation by setting errno variable to an
appropriate value. The value macros are documented in POSIX 2017.
@ppisar ppisar force-pushed the solv_xfopen_unsupported_error branch from 7a80f35 to fee6928 Compare May 15, 2024 14:57
@ppisar
Copy link
Contributor Author

ppisar commented May 15, 2024

I removed the guards.

@mlschroe mlschroe merged commit a898731 into openSUSE:master May 16, 2024
@mlschroe
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants