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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions ext/solv_xfopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>

#ifdef _WIN32
#include "fmemopen.c"
Expand Down Expand Up @@ -660,7 +661,10 @@ solv_xfopen(const char *fn, const char *mode)
char *suf;

if (!fn)
return 0;
{
errno = EINVAL;
return 0;
}
if (!mode)
mode = "r";
suf = strrchr(fn, '.');
Expand All @@ -669,7 +673,10 @@ solv_xfopen(const char *fn, const char *mode)
return mygzfopen(fn, mode);
#else
if (suf && !strcmp(suf, ".gz"))
return 0;
{
errno = ENOTSUP;
return 0;
}
#endif
#ifdef ENABLE_LZMA_COMPRESSION
if (suf && !strcmp(suf, ".xz"))
Expand All @@ -678,30 +685,45 @@ solv_xfopen(const char *fn, const char *mode)
return mylzfopen(fn, mode);
#else
if (suf && !strcmp(suf, ".xz"))
return 0;
{
errno = ENOTSUP;
return 0;
}
if (suf && !strcmp(suf, ".lzma"))
return 0;
{
errno = ENOTSUP;
return 0;
}
#endif
#ifdef ENABLE_BZIP2_COMPRESSION
if (suf && !strcmp(suf, ".bz2"))
return mybzfopen(fn, mode);
#else
if (suf && !strcmp(suf, ".bz2"))
return 0;
{
errno = ENOTSUP;
return 0;
}
#endif
#ifdef ENABLE_ZSTD_COMPRESSION
if (suf && !strcmp(suf, ".zst"))
return myzstdfopen(fn, mode);
#else
if (suf && !strcmp(suf, ".zst"))
return 0;
{
errno = ENOTSUP;
return 0;
}
#endif
#ifdef ENABLE_ZCHUNK_COMPRESSION
if (suf && !strcmp(suf, ".zck"))
return myzchunkfopen(fn, mode);
#else
if (suf && !strcmp(suf, ".zck"))
return 0;
{
errno = ENOTSUP;
return 0;
}
#endif
return fopen(fn, mode);
}
Expand Down