Skip to content

Commit ea879e1

Browse files
committed
Update NEWS and prevent negative rlen on erroneous INFO/END, #1006
1 parent ca2f667 commit ea879e1

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

NEWS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Noteworthy changes in release a.b
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4+
Noteworthy changes in release 1.10.1 (17th December 2019)
5+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
7+
The support for 64-bit coordinates in VCF brought problems for files
8+
not conforming to VCF/BCF specification. While previous versions would
9+
make out-of-range values silently overflow creating nonsense values
10+
but parseable file, the version 1.10 would silently create an invalid BCF.
11+
12+
413
Noteworthy changes in release 1.10 (6th December 2019)
514
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
615

vcf.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,7 +2521,7 @@ static int vcf_parse_format(kstring_t *s, const bcf_hdr_t *h, bcf1_t *v, char *p
25212521

25222522
int vcf_parse(kstring_t *s, const bcf_hdr_t *h, bcf1_t *v)
25232523
{
2524-
static int extreme_int_warned = 0;
2524+
static int extreme_int_warned = 0, negative_rlen_warned = 0;
25252525
int i = 0;
25262526
char *p, *q, *r, *t;
25272527
kstring_t *str;
@@ -2786,7 +2786,18 @@ int vcf_parse(kstring_t *s, const bcf_hdr_t *h, bcf1_t *v)
27862786
bcf_enc_vint(str, n_val, val_a, -1);
27872787
}
27882788
if (n_val==1 && strcmp(key, "END") == 0)
2789-
v->rlen = val1 - v->pos;
2789+
{
2790+
if ( val1 <= v->pos )
2791+
{
2792+
if ( !negative_rlen_warned )
2793+
{
2794+
hts_log_warning("INFO/END=%"PRIhts_pos" is smaller than POS at %s:%"PRIhts_pos,val1,bcf_seqname(h,v),v->pos+1);
2795+
negative_rlen_warned = 1;
2796+
}
2797+
}
2798+
else
2799+
v->rlen = val1 - v->pos;
2800+
}
27902801
} else if ((y>>4&0xf) == BCF_HT_REAL) {
27912802
float *val_f = (float *)val_a;
27922803
for (i = 0, t = val; i < n_val; ++i, ++t)

0 commit comments

Comments
 (0)