Skip to content

Commit

Permalink
Protect against CRAM compression headers having negative ref_seq_start.
Browse files Browse the repository at this point in the history
This could trigger buffer read overruns in the MD5 calculation code
(and perhaps more).

Credit to OSS-Fuzz
Fixes oss-fuzz 20694
  • Loading branch information
jkbonfield committed Feb 14, 2020
1 parent bfc9f0d commit ee06735
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cram/cram_decode.c
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

0 comments on commit ee06735

Please sign in to comment.