Skip to content

Commit 6811ac5

Browse files
committed
Release 1.15.1
2 parents 762d1b1 + e005af5 commit 6811ac5

File tree

13 files changed

+70
-27
lines changed

13 files changed

+70
-27
lines changed

NEWS

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
Noteworthy changes in release 1.15.1 (7th April 2022)
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
* Security fix: Fixed broken error reporting in the sam_cap_mapq()
5+
function, due to a missing hts_log() parameter. Prior to this fix
6+
it was possible to abuse the log message format string by passing
7+
a specially crafted alignment record to this function. (PR#1406)
8+
9+
* HTSlib now uses libhtscodecs release 1.2.2. This fixes a number
10+
of bugs where invalid compressed data could trigger usage of
11+
uninitialised values. (PR#1416)
12+
13+
* Fixed excessive memory used by multi-threaded SAM output on
14+
long reads. (Part of PR#1384)
15+
16+
* Fixed a bug where tabix would misinterpret region specifiers
17+
starting at position 0. It will also now warn if the file
18+
being indexed is supposed to be 1-based but has positions
19+
less than or equal to 0. (PR#1411)
20+
21+
* The VCF header parser will now issue a warning if it finds an
22+
INFO header with Type=Flag but Number not equal to 0. It will
23+
also ignore the incorrect Number so the flag can be used. (PR#1415)
24+
125
Noteworthy changes in release 1.15 (21st February 2022)
226
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327

bgzip.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH bgzip 1 "21 February 2022" "htslib-1.15" "Bioinformatics tools"
1+
.TH bgzip 1 "7 April 2022" "htslib-1.15.1" "Bioinformatics tools"
22
.SH NAME
33
.PP
44
bgzip \- Block compression/decompression utility

hts.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3711,14 +3711,17 @@ const char *hts_parse_region(const char *s, int *tid, hts_pos_t *beg,
37113711
char *hyphen;
37123712
*beg = hts_parse_decimal(colon+1, &hyphen, flags) - 1;
37133713
if (*beg < 0) {
3714+
if (*beg != -1 && *hyphen == '-' && colon[1] != '\0') {
3715+
// User specified zero, but we're 1-based.
3716+
hts_log_error("Coordinates must be > 0");
3717+
return NULL;
3718+
}
37143719
if (isdigit_c(*hyphen) || *hyphen == '\0' || *hyphen == ',') {
37153720
// interpret chr:-100 as chr:1-100
37163721
*end = *beg==-1 ? HTS_POS_MAX : -(*beg+1);
37173722
*beg = 0;
37183723
return s_end;
3719-
} else if (*hyphen == '-') {
3720-
*beg = 0;
3721-
} else {
3724+
} else if (*beg < -1) {
37223725
hts_log_error("Unexpected string \"%s\" after region", hyphen);
37233726
return NULL;
37243727
}

htsfile.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH htsfile 1 "21 February 2022" "htslib-1.15" "Bioinformatics tools"
1+
.TH htsfile 1 "7 April 2022" "htslib-1.15.1" "Bioinformatics tools"
22
.SH NAME
33
htsfile \- identify high-throughput sequencing data files
44
.\"

htslib-s3-plugin.7

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH htslib-s3-plugin 7 "21 February 2022" "htslib-1.15" "Bioinformatics tools"
1+
.TH htslib-s3-plugin 7 "7 April 2022" "htslib-1.15.1" "Bioinformatics tools"
22
.SH NAME
33
s3 plugin \- htslib AWS S3 plugin
44
.\"

htslib/hts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ const char *hts_version(void);
486486
// Immediately after release, bump ZZ to 90 to distinguish in-development
487487
// Git repository builds from the release; you may wish to increment this
488488
// further when significant features are merged.
489-
#define HTS_VERSION 101500
489+
#define HTS_VERSION 101501
490490

491491
/*! @abstract Introspection on the features enabled in htslib
492492
*

realn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ int sam_cap_mapq(bam1_t *b, const char *ref, hts_pos_t ref_len, int thres)
9191
static int realn_check_tag(const uint8_t *tg, enum htsLogLevel severity,
9292
const char *type, const bam1_t *b) {
9393
if (*tg != 'Z') {
94-
hts_log(severity, "Incorrect %s tag type (%c) for read %s",
94+
hts_log(severity, __func__, "Incorrect %s tag type (%c) for read %s",
9595
type, *tg, bam_get_qname(b));
9696
return -1;
9797
}
9898
if (b->core.l_qseq != strlen((const char *) tg + 1)) {
99-
hts_log(severity, "Read %s %s tag is wrong length",
99+
hts_log(severity, __func__, "Read %s %s tag is wrong length",
100100
bam_get_qname(b), type);
101101
return -1;
102102
}

sam.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,9 +2906,10 @@ ssize_t bam_parse_cigar(const char *in, char **end, bam1_t *b) {
29062906
* SAM threading
29072907
*/
29082908
// Size of SAM text block (reading)
2909-
#define NM 240000
2910-
// Number of BAM records (writing)
2911-
#define NB 1000
2909+
#define SAM_NBYTES 240000
2910+
2911+
// Number of BAM records (writing, up to NB_mem in size)
2912+
#define SAM_NBAM 1000
29122913

29132914
struct SAM_state;
29142915

@@ -2918,7 +2919,8 @@ typedef struct sp_bams {
29182919
int serial;
29192920

29202921
bam1_t *bams;
2921-
int nbams, abams; // used and alloc
2922+
int nbams, abams; // used and alloc for bams[] array
2923+
size_t bam_mem; // very approximate total size
29222924

29232925
struct SAM_state *fd;
29242926
} sp_bams;
@@ -3169,6 +3171,7 @@ static void *sam_parse_worker(void *arg) {
31693171
goto err;
31703172
}
31713173
gb->nbams = 0;
3174+
gb->bam_mem = 0;
31723175
}
31733176
gb->serial = gl->serial;
31743177
gb->next = NULL;
@@ -3221,6 +3224,7 @@ static void *sam_parse_worker(void *arg) {
32213224
cleanup_sp_lines(gl);
32223225
goto err;
32233226
}
3227+
32243228
cp = nl;
32253229
i++;
32263230
}
@@ -3290,7 +3294,7 @@ static void *sam_dispatcher_read(void *vp) {
32903294
l = calloc(1, sizeof(*l));
32913295
if (!l)
32923296
goto err;
3293-
l->alloc = NM;
3297+
l->alloc = SAM_NBYTES;
32943298
l->data = malloc(l->alloc+8); // +8 for optimisation in sam_parse1
32953299
if (!l->data) {
32963300
free(l);
@@ -3301,11 +3305,11 @@ static void *sam_dispatcher_read(void *vp) {
33013305
}
33023306
l->next = NULL;
33033307

3304-
if (l->alloc < line_frag+NM/2) {
3305-
char *rp = realloc(l->data, line_frag+NM/2 +8);
3308+
if (l->alloc < line_frag+SAM_NBYTES/2) {
3309+
char *rp = realloc(l->data, line_frag+SAM_NBYTES/2 +8);
33063310
if (!rp)
33073311
goto err;
3308-
l->alloc = line_frag+NM/2;
3312+
l->alloc = line_frag+SAM_NBYTES/2;
33093313
l->data = rp;
33103314
}
33113315
memcpy(l->data, line.s, line_frag);
@@ -4302,16 +4306,18 @@ int sam_write1(htsFile *fp, const sam_hdr_t *h, const bam1_t *b)
43024306
fd->bams = gb->next;
43034307
gb->next = NULL;
43044308
gb->nbams = 0;
4309+
gb->bam_mem = 0;
43054310
pthread_mutex_unlock(&fd->lines_m);
43064311
} else {
43074312
pthread_mutex_unlock(&fd->lines_m);
43084313
if (!(gb = calloc(1, sizeof(*gb)))) return -1;
4309-
if (!(gb->bams = calloc(NB, sizeof(*gb->bams)))) {
4314+
if (!(gb->bams = calloc(SAM_NBAM, sizeof(*gb->bams)))) {
43104315
free(gb);
43114316
return -1;
43124317
}
43134318
gb->nbams = 0;
4314-
gb->abams = NB;
4319+
gb->abams = SAM_NBAM;
4320+
gb->bam_mem = 0;
43154321
gb->fd = fd;
43164322
fd->curr_idx = 0;
43174323
fd->curr_bam = gb;
@@ -4320,11 +4326,11 @@ int sam_write1(htsFile *fp, const sam_hdr_t *h, const bam1_t *b)
43204326

43214327
if (!bam_copy1(&gb->bams[gb->nbams++], b))
43224328
return -2;
4329+
gb->bam_mem += b->l_data + sizeof(*b);
43234330

43244331
// Dispatch if full
4325-
if (gb->nbams == NB) {
4332+
if (gb->nbams == SAM_NBAM || gb->bam_mem > SAM_NBYTES*0.8) {
43264333
gb->serial = fd->serial++;
4327-
//fprintf(stderr, "Dispatch another %d bams\n", NB);
43284334
pthread_mutex_lock(&fd->command_m);
43294335
if (fd->errcode != 0) {
43304336
pthread_mutex_unlock(&fd->command_m);

tabix.1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH tabix 1 "21 February 2022" "htslib-1.15" "Bioinformatics tools"
1+
.TH tabix 1 "7 April 2022" "htslib-1.15.1" "Bioinformatics tools"
22
.SH NAME
33
.PP
44
tabix \- Generic indexer for TAB-delimited genome position files
@@ -81,8 +81,8 @@ greater than that, you will need to use a CSI index.
8181
.SH INDEXING OPTIONS
8282
.TP 10
8383
.B -0, --zero-based
84-
Specify that the position in the data file is 0-based (e.g. UCSC files)
85-
rather than 1-based.
84+
Specify that the position in the data file is 0-based half-open
85+
(e.g. UCSC files) rather than 1-based.
8686
.TP
8787
.BI "-b, --begin " INT
8888
Column of start chromosomal position. [4]

0 commit comments

Comments
 (0)