Skip to content

Commit

Permalink
Release 1.15.1
Browse files Browse the repository at this point in the history
  • Loading branch information
daviesrob committed Apr 7, 2022
2 parents 762d1b1 + e005af5 commit 6811ac5
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 27 deletions.
24 changes: 24 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
Noteworthy changes in release 1.15.1 (7th April 2022)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Security fix: Fixed broken error reporting in the sam_cap_mapq()
function, due to a missing hts_log() parameter. Prior to this fix
it was possible to abuse the log message format string by passing
a specially crafted alignment record to this function. (PR#1406)

* HTSlib now uses libhtscodecs release 1.2.2. This fixes a number
of bugs where invalid compressed data could trigger usage of
uninitialised values. (PR#1416)

* Fixed excessive memory used by multi-threaded SAM output on
long reads. (Part of PR#1384)

* Fixed a bug where tabix would misinterpret region specifiers
starting at position 0. It will also now warn if the file
being indexed is supposed to be 1-based but has positions
less than or equal to 0. (PR#1411)

* The VCF header parser will now issue a warning if it finds an
INFO header with Type=Flag but Number not equal to 0. It will
also ignore the incorrect Number so the flag can be used. (PR#1415)

Noteworthy changes in release 1.15 (21st February 2022)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion bgzip.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH bgzip 1 "21 February 2022" "htslib-1.15" "Bioinformatics tools"
.TH bgzip 1 "7 April 2022" "htslib-1.15.1" "Bioinformatics tools"
.SH NAME
.PP
bgzip \- Block compression/decompression utility
Expand Down
9 changes: 6 additions & 3 deletions hts.c
Original file line number Diff line number Diff line change
Expand Up @@ -3711,14 +3711,17 @@ const char *hts_parse_region(const char *s, int *tid, hts_pos_t *beg,
char *hyphen;
*beg = hts_parse_decimal(colon+1, &hyphen, flags) - 1;
if (*beg < 0) {
if (*beg != -1 && *hyphen == '-' && colon[1] != '\0') {
// User specified zero, but we're 1-based.
hts_log_error("Coordinates must be > 0");
return NULL;
}
if (isdigit_c(*hyphen) || *hyphen == '\0' || *hyphen == ',') {
// interpret chr:-100 as chr:1-100
*end = *beg==-1 ? HTS_POS_MAX : -(*beg+1);
*beg = 0;
return s_end;
} else if (*hyphen == '-') {
*beg = 0;
} else {
} else if (*beg < -1) {
hts_log_error("Unexpected string \"%s\" after region", hyphen);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion htsfile.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH htsfile 1 "21 February 2022" "htslib-1.15" "Bioinformatics tools"
.TH htsfile 1 "7 April 2022" "htslib-1.15.1" "Bioinformatics tools"
.SH NAME
htsfile \- identify high-throughput sequencing data files
.\"
Expand Down
2 changes: 1 addition & 1 deletion htslib-s3-plugin.7
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH htslib-s3-plugin 7 "21 February 2022" "htslib-1.15" "Bioinformatics tools"
.TH htslib-s3-plugin 7 "7 April 2022" "htslib-1.15.1" "Bioinformatics tools"
.SH NAME
s3 plugin \- htslib AWS S3 plugin
.\"
Expand Down
2 changes: 1 addition & 1 deletion htslib/hts.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ const char *hts_version(void);
// Immediately after release, bump ZZ to 90 to distinguish in-development
// Git repository builds from the release; you may wish to increment this
// further when significant features are merged.
#define HTS_VERSION 101500
#define HTS_VERSION 101501

/*! @abstract Introspection on the features enabled in htslib
*
Expand Down
4 changes: 2 additions & 2 deletions realn.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ int sam_cap_mapq(bam1_t *b, const char *ref, hts_pos_t ref_len, int thres)
static int realn_check_tag(const uint8_t *tg, enum htsLogLevel severity,
const char *type, const bam1_t *b) {
if (*tg != 'Z') {
hts_log(severity, "Incorrect %s tag type (%c) for read %s",
hts_log(severity, __func__, "Incorrect %s tag type (%c) for read %s",
type, *tg, bam_get_qname(b));
return -1;
}
if (b->core.l_qseq != strlen((const char *) tg + 1)) {
hts_log(severity, "Read %s %s tag is wrong length",
hts_log(severity, __func__, "Read %s %s tag is wrong length",
bam_get_qname(b), type);
return -1;
}
Expand Down
30 changes: 18 additions & 12 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -2906,9 +2906,10 @@ ssize_t bam_parse_cigar(const char *in, char **end, bam1_t *b) {
* SAM threading
*/
// Size of SAM text block (reading)
#define NM 240000
// Number of BAM records (writing)
#define NB 1000
#define SAM_NBYTES 240000

// Number of BAM records (writing, up to NB_mem in size)
#define SAM_NBAM 1000

struct SAM_state;

Expand All @@ -2918,7 +2919,8 @@ typedef struct sp_bams {
int serial;

bam1_t *bams;
int nbams, abams; // used and alloc
int nbams, abams; // used and alloc for bams[] array
size_t bam_mem; // very approximate total size

struct SAM_state *fd;
} sp_bams;
Expand Down Expand Up @@ -3169,6 +3171,7 @@ static void *sam_parse_worker(void *arg) {
goto err;
}
gb->nbams = 0;
gb->bam_mem = 0;
}
gb->serial = gl->serial;
gb->next = NULL;
Expand Down Expand Up @@ -3221,6 +3224,7 @@ static void *sam_parse_worker(void *arg) {
cleanup_sp_lines(gl);
goto err;
}

cp = nl;
i++;
}
Expand Down Expand Up @@ -3290,7 +3294,7 @@ static void *sam_dispatcher_read(void *vp) {
l = calloc(1, sizeof(*l));
if (!l)
goto err;
l->alloc = NM;
l->alloc = SAM_NBYTES;
l->data = malloc(l->alloc+8); // +8 for optimisation in sam_parse1
if (!l->data) {
free(l);
Expand All @@ -3301,11 +3305,11 @@ static void *sam_dispatcher_read(void *vp) {
}
l->next = NULL;

if (l->alloc < line_frag+NM/2) {
char *rp = realloc(l->data, line_frag+NM/2 +8);
if (l->alloc < line_frag+SAM_NBYTES/2) {
char *rp = realloc(l->data, line_frag+SAM_NBYTES/2 +8);
if (!rp)
goto err;
l->alloc = line_frag+NM/2;
l->alloc = line_frag+SAM_NBYTES/2;
l->data = rp;
}
memcpy(l->data, line.s, line_frag);
Expand Down Expand Up @@ -4302,16 +4306,18 @@ int sam_write1(htsFile *fp, const sam_hdr_t *h, const bam1_t *b)
fd->bams = gb->next;
gb->next = NULL;
gb->nbams = 0;
gb->bam_mem = 0;
pthread_mutex_unlock(&fd->lines_m);
} else {
pthread_mutex_unlock(&fd->lines_m);
if (!(gb = calloc(1, sizeof(*gb)))) return -1;
if (!(gb->bams = calloc(NB, sizeof(*gb->bams)))) {
if (!(gb->bams = calloc(SAM_NBAM, sizeof(*gb->bams)))) {
free(gb);
return -1;
}
gb->nbams = 0;
gb->abams = NB;
gb->abams = SAM_NBAM;
gb->bam_mem = 0;
gb->fd = fd;
fd->curr_idx = 0;
fd->curr_bam = gb;
Expand All @@ -4320,11 +4326,11 @@ int sam_write1(htsFile *fp, const sam_hdr_t *h, const bam1_t *b)

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

// Dispatch if full
if (gb->nbams == NB) {
if (gb->nbams == SAM_NBAM || gb->bam_mem > SAM_NBYTES*0.8) {
gb->serial = fd->serial++;
//fprintf(stderr, "Dispatch another %d bams\n", NB);
pthread_mutex_lock(&fd->command_m);
if (fd->errcode != 0) {
pthread_mutex_unlock(&fd->command_m);
Expand Down
6 changes: 3 additions & 3 deletions tabix.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH tabix 1 "21 February 2022" "htslib-1.15" "Bioinformatics tools"
.TH tabix 1 "7 April 2022" "htslib-1.15.1" "Bioinformatics tools"
.SH NAME
.PP
tabix \- Generic indexer for TAB-delimited genome position files
Expand Down Expand Up @@ -81,8 +81,8 @@ greater than that, you will need to use a CSI index.
.SH INDEXING OPTIONS
.TP 10
.B -0, --zero-based
Specify that the position in the data file is 0-based (e.g. UCSC files)
rather than 1-based.
Specify that the position in the data file is 0-based half-open
(e.g. UCSC files) rather than 1-based.
.TP
.BI "-b, --begin " INT
Column of start chromosomal position. [4]
Expand Down
6 changes: 5 additions & 1 deletion tbx.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ int tbx_parse1(const tbx_conf_t *conf, int len, char *line, tbx_intv_t *intv)
if ( s==line+b ) return -1; // expected int
if (!(conf->preset&TBX_UCSC)) --intv->beg;
else ++intv->end;
if (intv->beg < 0) intv->beg = 0;
if (intv->beg < 0) {
hts_log_warning("Coordinate <= 0 detected. "
"Did you forget to use the -0 option?");
intv->beg = 0;
}
if (intv->end < 1) intv->end = 1;
} else {
if ((conf->preset&0xffff) == TBX_GENERIC) {
Expand Down
6 changes: 6 additions & 0 deletions vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,12 @@ static int bcf_hdr_register_hrec(bcf_hdr_t *hdr, bcf_hrec_t *hrec)
*hrec->key == 'I' ? "An" : "A", hrec->key);
var = BCF_VL_VAR;
}
if ( type==BCF_HT_FLAG && (var!=BCF_VL_FIXED || num!=0) )
{
hts_log_warning("The definition of Flag \"%s/%s\" is invalid, forcing Number=0", hrec->key,id);
var = BCF_VL_FIXED;
num = 0;
}
}
uint32_t info = ((((uint32_t)num) & 0xfffff)<<12 |
(var & 0xf) << 8 |
Expand Down
2 changes: 1 addition & 1 deletion version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# DEALINGS IN THE SOFTWARE.

# Master version, for use in tarballs or non-git source copies
VERSION=1.15
VERSION=1.15.1

# If we have a git clone, then check against the current tag
srcdir=${0%/version.sh}
Expand Down

0 comments on commit 6811ac5

Please sign in to comment.