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

Fix crypt4gh redirection #1577

Merged
merged 1 commit into from
Mar 7, 2023
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
4 changes: 3 additions & 1 deletion hts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,7 @@ static int hts_crypt4gh_redirect(const char *fn, const char *mode,
hFILE *hfile1 = *hfile_ptr;
hFILE *hfile2 = NULL;
char fn_buf[512], *fn2 = fn_buf;
char mode2[102]; // Size set by sizeof(simple_mode) in hts_hopen()
const char *prefix = "crypt4gh:";
size_t fn2_len = strlen(prefix) + strlen(fn) + 1;
int ret = -1;
Expand All @@ -1362,7 +1363,8 @@ static int hts_crypt4gh_redirect(const char *fn, const char *mode,

// Reopen fn using the crypt4gh plug-in (if available)
snprintf(fn2, fn2_len, "%s%s", prefix, fn);
hfile2 = hopen(fn2, mode, "parent", hfile1, NULL);
snprintf(mode2, sizeof(mode2), "%s%s", mode, strchr(mode, ':') ? "" : ":");
hfile2 = hopen(fn2, mode2, "parent", hfile1, NULL);
if (hfile2) {
// Replace original hfile with the new one. The original is now
// enclosed within hfile2
Expand Down