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

Permit BAM headers between 2GB and 4GB in size once more. #1421

Merged
merged 1 commit into from
Apr 13, 2022
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
10 changes: 8 additions & 2 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,23 @@ int bam_hdr_write(BGZF *fp, const sam_hdr_t *h)

if (h->hrecs) {
if (sam_hrecs_rebuild_text(h->hrecs, &hdr_ks) != 0) return -1;
if (hdr_ks.l > INT32_MAX) {
if (hdr_ks.l > UINT32_MAX) {
hts_log_error("Header too long for BAM format");
free(hdr_ks.s);
return -1;
} else if (hdr_ks.l > INT32_MAX) {
hts_log_warning("Header too long for BAM specification (>2GB)");
hts_log_warning("Output file may not be portable");
}
text = hdr_ks.s;
l_text = hdr_ks.l;
} else {
if (h->l_text > INT32_MAX) {
if (h->l_text > UINT32_MAX) {
hts_log_error("Header too long for BAM format");
return -1;
} else if (h->l_text > INT32_MAX) {
hts_log_warning("Header too long for BAM specification (>2GB)");
hts_log_warning("Output file may not be portable");
}
text = h->text;
l_text = h->l_text;
Expand Down