de609b7489963f32ad474619cb3dff0283ef7e76
braney
  Sun Aug 23 15:13:46 2026 -0700
vcf: bound the genotype allele index by the field it is stored in, refs #38155

parseAlleleIx checked the index against alleleCount only. A record can hold up
to VCF_MAX_INFO alleles, so an index of 128 or more could pass that check and
then narrow on the way into the signed char field. The narrowed value was
sometimes another real allele of the record: with 260 ALT alleles, index 260
came out as 4. The parser then reported a genotype the VCF never named.

The check now also rejects an index above SCHAR_MAX, so an index too large for
the field reads as missing data. SCHAR_MAX and not CHAR_MAX, because CHAR_MAX
is 255 on the unsigned char platforms that the field is declared signed for.

Every other assignment to hapIxA and hapIxB in this file is a literal in the
range -1 to 2, so parseAlleleIx was the only path that could carry an
out-of-range value.

New test vcfParseManyAlleles, with a record of 260 ALT alleles. Without the
fix, GT 128/1 reads as -128/1, 130/130 as -126/-126, and 260/260 as 4/4.

diff --git src/lib/tests/input/manyAlleles.vcf.gz src/lib/tests/input/manyAlleles.vcf.gz
new file mode 100644
index 00000000000..9399bcc783b
Binary files /dev/null and src/lib/tests/input/manyAlleles.vcf.gz differ