Skip to content

Commit

Permalink
Fix duplicated but missing FORMAT bug
Browse files Browse the repository at this point in the history
7ce510c added code to drop duplicate FORMAT tags, but missed the
case where the duplicated entry was off the end of the per-sample
data, so it hit the part that put in MISSING values.  This lead
to an attempt to call memset() with a negative size.  Fixed by
adding code to skip the duplicated FORMAT tag.

Credit to OSS-Fuzz
Fixes oss-fuzz 67431
  • Loading branch information
daviesrob authored and pd3 committed Mar 21, 2024
1 parent ca0f621 commit 6ea61bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/noroundtrip-out.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
##FILTER=<ID=PASS,Description="All filters passed">
##contig=<ID=3>
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##FORMAT=<ID=S,Number=1,Type=String,Description="Non-GT string">
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA1
3 50 . A T 0 PASS . GT 0/1
3 60 . T C 0 PASS . GT 0/1
3 70 . G A 0 PASS . GT 0/1
3 80 . C G 0 PASS . GT 0/1
3 90 . A G 0 PASS . GT:S 0/1:.
2 changes: 2 additions & 0 deletions test/noroundtrip.vcf
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
##fileformat=VCFv4.3
##contig=<ID=3>
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##FORMAT=<ID=S,Number=1,Type=String,Description="Non-GT string">
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA1
3 50 . A T 0 PASS . GT:GT 0/1
3 60 . T C 0 PASS . GT 0/1
3 70 . G A 0 PASS . GT:GT 0/1:.
3 80 . C G 0 PASS . GT:GT 0/1:0/1
3 90 . A G 0 PASS . GT:S:S 0/1
4 changes: 4 additions & 0 deletions vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3234,6 +3234,10 @@ static int vcf_parse_format_fill5(kstring_t *s, const bcf_hdr_t *h, bcf1_t *v,
fmt_aux_t *z = &fmt[j];
const int htype = z->y>>4&0xf;
int l;

if (z->size == -1) // this field is to be ignored
continue;

if (htype == BCF_HT_STR) {
if (z->is_gt) {
int32_t *x = (int32_t*)(z->buf + z->size * (size_t)m);
Expand Down

0 comments on commit 6ea61bf

Please sign in to comment.