Skip to content

Commit

Permalink
Protect against CRAM slice end going beyond end of reference.
Browse files Browse the repository at this point in the history
This was checked for with aligned data, but unmapped "placed" reads
could start beyind the reference end and cr->aend was dutifully set
where it claimed to start. This could cause buffer read-overruns when
computing the reference md5.

Fixes #1698, fixes #1700
  • Loading branch information
jkbonfield committed Nov 17, 2023
1 parent 99bf38d commit 86691e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cram/cram_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3558,7 +3558,7 @@ static int process_one_read(cram_fd *fd, cram_container *c,
cr->cigar = 0;
cr->ncigar = 0;
cr->nfeature = 0;
cr->aend = cr->apos;
cr->aend = MIN(cr->apos, c->ref_end);
for (i = 0; i < cr->len; i++)
if (cram_stats_add(c->stats[DS_BA], seq[i]) < 0)
goto block_err;
Expand Down

0 comments on commit 86691e8

Please sign in to comment.