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

Check that handler->isremote has been set before calling it. #1757

Merged
merged 1 commit into from
Mar 21, 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
15 changes: 13 additions & 2 deletions hfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,11 +884,18 @@ char *hfile_mem_steal_buffer(hFILE *file, size_t *length) {
return buf;
}

// open() stub for mem: which only works with the vopen() interface
// Use 'data:,' for data encoded in the URL
static hFILE *hopen_not_supported(const char *fname, const char *mode) {
errno = EINVAL;
return NULL;
}

int hfile_plugin_init_mem(struct hFILE_plugin *self)
{
// mem files are declared remote so they work with a tabix index
static const struct hFILE_scheme_handler handler =
{NULL, hfile_always_remote, "mem", 2000 + 50, hopenv_mem};
{hopen_not_supported, hfile_always_remote, "mem", 2000 + 50, hopenv_mem};
self->name = "mem";
hfile_add_scheme_handler("mem", &handler);
return 0;
Expand Down Expand Up @@ -923,7 +930,7 @@ static hFILE *crypt4gh_needed(const char *url, const char *mode)
int hfile_plugin_init_crypt4gh_needed(struct hFILE_plugin *self)
{
static const struct hFILE_scheme_handler handler =
{ crypt4gh_needed, NULL, "crypt4gh-needed", 0, NULL };
{ crypt4gh_needed, hfile_always_local, "crypt4gh-needed", 0, NULL };
self->name = "crypt4gh-needed";
hfile_add_scheme_handler("crypt4gh", &handler);
return 0;
Expand Down Expand Up @@ -1022,6 +1029,10 @@ void hfile_add_scheme_handler(const char *scheme,
const struct hFILE_scheme_handler *handler)
{
int absent;
if (handler->open == NULL || handler->isremote == NULL) {
hts_log_warning("Couldn't register scheme handler for %s: missing method", scheme);
return;
}
if (!schemes) {
if (try_exe_add_scheme_handler(scheme, handler) != 0) {
hts_log_warning("Couldn't register scheme handler for %s", scheme);
Expand Down