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

Protect against CRAM compression headers having negative ref_seq_start. #1024

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions cram/cram_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,12 @@ cram_block_slice_hdr *cram_decode_slice_header(cram_fd *fd, cram_block *b) {
cp += safe_itf8_get((char *)cp, (char *)cp_end, &i32);
hdr->ref_seq_span = i32;
#endif
if (hdr->ref_seq_start < 0 || hdr->ref_seq_span < 0) {
free(hdr);
hts_log_error("Negative values not permitted for header "
"sequence start or span fields");
return NULL;
}
}
cp += safe_itf8_get((char *)cp, (char *)cp_end, &hdr->num_records);
hdr->record_counter = 0;
Expand Down