Skip to content

Commit 746549d

Browse files
committed
Release 1.6: hfile_libcurl improvements; more checks on input files
2 parents 49fdfbd + a889c7f commit 746549d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1733
-569
lines changed

.appveyor.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# version format.
2+
# you can use {branch} name in version format too
3+
# version: 1.0.{build}-{branch}
4+
version: 'vers.{build}'
5+
6+
# branches to build
7+
branches:
8+
# Whitelist
9+
only:
10+
- develop
11+
12+
# Blacklist
13+
except:
14+
- gh-pages
15+
16+
# Do not build on tags (GitHub and BitBucket)
17+
skip_tags: true
18+
19+
# Skipping commits affecting specific files (GitHub only). More details here: /docs/appveyor-yml
20+
#skip_commits:
21+
# files:
22+
# - docs/*
23+
# - '**/*.html'
24+
25+
# We use Mingw/Msys, so use pacman for installs
26+
install:
27+
- set HOME=.
28+
- set MSYSTEM=MINGW64
29+
- set PATH=C:/msys64/usr/bin;C:/msys64/mingw64/bin;%PATH%
30+
- set MINGWPREFIX=x86_64-w64-mingw32
31+
- "sh -lc \"pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-zlib mingw-w64-x86_64-bzip2 mingw-w64-x86_64-xz mingw-w64-x86_64-curl\""
32+
33+
build_script:
34+
- set HOME=.
35+
- set MSYSTEM=MINGW64
36+
- set PATH=C:/msys64/usr/bin;C:/msys64/mingw64/bin;%PATH%
37+
- "sh -lc \"aclocal && autoheader && autoconf && ./configure && make -j2\""
38+
39+
#build_script:
40+
# - make
41+
42+
test_script:
43+
- "sh -lc \"make test\""

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@
1010
.git* export-ignore
1111
/.travis.yml export-ignore
1212
README.md export-ignore
13+
14+
# Remove the text attribute from reference files, so that git doesn't convert
15+
# line separators on Windows machines. It causes the index files to become out
16+
# of sync with the fasta files.
17+
*.fa* -text

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
*.o
22
*.pico
3+
*.obj
34
*.dSYM
45
*.exe
6+
*.dll
57
*.pc.tmp
68
*-uninstalled.pc
79
/version.h

INSTALL

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ library is used. Systems that do not have CChmac will get this from
4848
libcrypto. libcrypto is part of OpenSSL or one of its derivatives (LibreSSL
4949
or BoringSSL).
5050

51+
On Microsoft Windows we recommend use of Mingw64/Msys2. Note that
52+
currently for the test harness to work you will need to override the
53+
test temporary directory with e.g.: make check TEST_OPTS="-t C:/msys64/tmp/_"
54+
Whilst the code may work on Windows with other environments, these have
55+
not be verified.
56+
5157
Building Configure
5258
==================
5359

Makefile

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ BUILT_TEST_PROGRAMS = \
7676
test/test_view \
7777
test/test-vcf-api \
7878
test/test-vcf-sweep \
79-
test/test-bcf-sr
79+
test/test-bcf-sr \
80+
test/test-bcf-translate
8081

8182
BUILT_THRASH_PROGRAMS = \
8283
test/thrash_threads1 \
@@ -91,42 +92,27 @@ all: lib-static lib-shared $(BUILT_PROGRAMS) plugins $(BUILT_TEST_PROGRAMS)
9192
HTSPREFIX =
9293
include htslib_vars.mk
9394

94-
95-
PACKAGE_VERSION = 1.5
95+
# If not using GNU make, you need to copy the version number from version.sh
96+
# into here.
97+
PACKAGE_VERSION := $(shell ./version.sh)
9698
LIBHTS_SOVERSION = 2
9799

98-
99100
# $(NUMERIC_VERSION) is for items that must have a numeric X.Y.Z string
100101
# even if this is a dirty or untagged Git working tree.
101-
NUMERIC_VERSION = $(PACKAGE_VERSION)
102-
103-
# If building from a Git repository, replace $(PACKAGE_VERSION) with the Git
104-
# description of the working tree: either a release tag with the same value
105-
# as $(PACKAGE_VERSION) above, or an exact description likely based on a tag.
106-
# Much of this is also GNU Make-specific. If you don't have GNU Make and/or
107-
# are not building from a Git repository, comment out this conditional.
108-
ifneq "$(wildcard .git)" ""
109-
original_version := $(PACKAGE_VERSION)
110-
PACKAGE_VERSION := $(shell git describe --always --dirty)
111-
112-
# Unless the Git description matches /\d*\.\d*(\.\d*)?/, i.e., is exactly a tag
113-
# with a numeric name, revert $(NUMERIC_VERSION) to the original version number
114-
# written above, but with the patchlevel field bumped to 255.
115-
ifneq "$(subst ..,.,$(subst 0,,$(subst 1,,$(subst 2,,$(subst 3,,$(subst 4,,$(subst 5,,$(subst 6,,$(subst 7,,$(subst 8,,$(subst 9,,$(PACKAGE_VERSION))))))))))))" "."
116-
empty :=
117-
NUMERIC_VERSION := $(subst $(empty) ,.,$(wordlist 1,2,$(subst ., ,$(original_version))) 255)
118-
endif
102+
NUMERIC_VERSION := $(shell ./version.sh numeric)
119103

120104
# Force version.h to be remade if $(PACKAGE_VERSION) has changed.
121105
version.h: $(if $(wildcard version.h),$(if $(findstring "$(PACKAGE_VERSION)",$(shell cat version.h)),,force))
122-
endif
123106

124107
version.h:
125108
echo '#define HTS_VERSION "$(PACKAGE_VERSION)"' > $@
126109

127110
print-version:
128111
@echo $(PACKAGE_VERSION)
129112

113+
show-version:
114+
@echo PACKAGE_VERSION = $(PACKAGE_VERSION)
115+
@echo NUMERIC_VERSION = $(NUMERIC_VERSION)
130116

131117
.SUFFIXES: .bundle .c .cygdll .dll .o .pico .so
132118

@@ -148,6 +134,7 @@ LIBHTS_OBJS = \
148134
hfile.o \
149135
hfile_net.o \
150136
hts.o \
137+
hts_os.o\
151138
md5.o \
152139
multipart.o \
153140
probaln.o \
@@ -208,6 +195,8 @@ config.h:
208195
echo '/* Default config.h generated by Makefile */' > $@
209196
echo '#define HAVE_LIBBZ2 1' >> $@
210197
echo '#define HAVE_LIBLZMA 1' >> $@
198+
echo '#define HAVE_FSEEKO 1' >> $@
199+
echo '#define HAVE_DRAND48 1' >> $@
211200

212201
# And similarly for htslib.pc.tmp ("pkg-config template"). No dependency
213202
# on htslib.pc.in listed, as if that file is newer the usual way to regenerate
@@ -235,6 +224,9 @@ lib-shared: libhts.dylib
235224
else ifeq "$(findstring CYGWIN,$(PLATFORM))" "CYGWIN"
236225
SHLIB_FLAVOUR = cygdll
237226
lib-shared: cyghts-$(LIBHTS_SOVERSION).dll
227+
else ifeq "$(findstring MSYS,$(PLATFORM))" "MSYS"
228+
SHLIB_FLAVOUR = dll
229+
lib-shared: hts-$(LIBHTS_SOVERSION).dll
238230
else
239231
SHLIB_FLAVOUR = so
240232
lib-shared: libhts.so
@@ -276,6 +268,9 @@ libhts.dylib: $(LIBHTS_OBJS)
276268
cyghts-$(LIBHTS_SOVERSION).dll: $(LIBHTS_OBJS)
277269
$(CC) -shared -Wl,--out-implib=libhts.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) -lpthread
278270

271+
hts-$(LIBHTS_SOVERSION).dll: $(LIBHTS_OBJS)
272+
$(CC) -shared -Wl,--out-implib=hts.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) -lpthread
273+
279274

280275
.pico.so:
281276
$(CC) -shared -Wl,-E $(LDFLAGS) -o $@ $< $(LIBS) -lpthread
@@ -286,6 +281,9 @@ cyghts-$(LIBHTS_SOVERSION).dll: $(LIBHTS_OBJS)
286281
.o.cygdll:
287282
$(CC) -shared $(LDFLAGS) -o $@ $< libhts.dll.a $(LIBS)
288283

284+
.o.dll:
285+
$(CC) -shared $(LDFLAGS) -o $@ $< hts.dll.a $(LIBS)
286+
289287

290288
bgzf.o bgzf.pico: bgzf.c config.h $(htslib_hts_h) $(htslib_bgzf_h) $(htslib_hfile_h) $(htslib_thread_pool_h) cram/pooled_alloc.h $(htslib_khash_h)
291289
errmod.o errmod.pico: errmod.c config.h $(htslib_hts_h) $(htslib_ksort_h)
@@ -348,6 +346,9 @@ tabix.o: tabix.c config.h $(htslib_tbx_h) $(htslib_sam_h) $(htslib_vcf_h) $(htsl
348346

349347
# For tests that might use it, set $REF_PATH explicitly to use only reference
350348
# areas within the test suite (or set it to ':' to use no reference areas).
349+
#
350+
# If using MSYS, avoid poor shell expansion via:
351+
# MSYS2_ARG_CONV_EXCL="*" make check
351352
check test: $(BUILT_PROGRAMS) $(BUILT_TEST_PROGRAMS)
352353
test/hts_endian
353354
test/fieldarith test/fieldarith.sam
@@ -356,7 +357,7 @@ check test: $(BUILT_PROGRAMS) $(BUILT_TEST_PROGRAMS)
356357
cd test/tabix && ./test-tabix.sh tabix.tst
357358
REF_PATH=: test/sam test/ce.fa test/faidx.fa
358359
test/test-regidx
359-
cd test && REF_PATH=: ./test.pl
360+
cd test && REF_PATH=: ./test.pl $${TEST_OPTS:-}
360361

361362
test/hts_endian: test/hts_endian.o
362363
$(CC) $(LDFLAGS) -o $@ test/hts_endian.o $(LIBS)
@@ -388,6 +389,9 @@ test/test-vcf-sweep: test/test-vcf-sweep.o libhts.a
388389
test/test-bcf-sr: test/test-bcf-sr.o libhts.a
389390
$(CC) $(LDFLAGS) -o $@ test/test-bcf-sr.o libhts.a -lz $(LIBS) -lpthread
390391

392+
test/test-bcf-translate: test/test-bcf-translate.o libhts.a
393+
$(CC) $(LDFLAGS) -o $@ test/test-bcf-translate.o libhts.a -lz $(LIBS) -lpthread
394+
391395
test/hts_endian.o: test/hts_endian.c $(htslib_hts_endian_h)
392396
test/fieldarith.o: test/fieldarith.c config.h $(htslib_sam_h)
393397
test/hfile.o: test/hfile.c config.h $(htslib_hfile_h) $(htslib_hts_defs_h)
@@ -398,6 +402,7 @@ test/test_view.o: test/test_view.c config.h $(cram_h) $(htslib_sam_h)
398402
test/test-vcf-api.o: test/test-vcf-api.c config.h $(htslib_hts_h) $(htslib_vcf_h) $(htslib_kstring_h) $(htslib_kseq_h)
399403
test/test-vcf-sweep.o: test/test-vcf-sweep.c config.h $(htslib_vcf_sweep_h)
400404
test/test-bcf-sr.o: test/test-bcf-sr.c config.h $(htslib_vcf_sweep_h) bcf_sr_sort.h
405+
test/test-bcf-translate.o: test/test-bcf-translate.c config.h
401406

402407

403408
test/thrash_threads1: test/thrash_threads1.o libhts.a
@@ -446,6 +451,10 @@ install-cygdll: cyghts-$(LIBHTS_SOVERSION).dll installdirs
446451
$(INSTALL_PROGRAM) cyghts-$(LIBHTS_SOVERSION).dll $(DESTDIR)$(bindir)/cyghts-$(LIBHTS_SOVERSION).dll
447452
$(INSTALL_PROGRAM) libhts.dll.a $(DESTDIR)$(libdir)/libhts.dll.a
448453

454+
install-dll: hts-$(LIBHTS_SOVERSION).dll installdirs
455+
$(INSTALL_PROGRAM) hts-$(LIBHTS_SOVERSION).dll $(DESTDIR)$(bindir)/hts-$(LIBHTS_SOVERSION).dll
456+
$(INSTALL_PROGRAM) hts.dll.a $(DESTDIR)$(libdir)/hts.dll.a
457+
449458
install-dylib: libhts.dylib installdirs
450459
$(INSTALL_PROGRAM) libhts.dylib $(DESTDIR)$(libdir)/libhts.$(PACKAGE_VERSION).dylib
451460
ln -sf libhts.$(PACKAGE_VERSION).dylib $(DESTDIR)$(libdir)/libhts.dylib
@@ -483,6 +492,9 @@ clean-so:
483492
clean-cygdll:
484493
-rm -f cyghts-*.dll libhts.dll.a
485494

495+
clean-dll:
496+
-rm -f hts-*.dll hts.dll.a
497+
486498
clean-dylib:
487499
-rm -f libhts.dylib libhts.*.dylib
488500

@@ -498,7 +510,8 @@ tags TAGS:
498510
# (The wildcards attempt to omit non-exported files (.git*, README.md,
499511
# etc) and other detritus that might be in the top-level directory.)
500512
distdir:
501-
tar -c *.[ch15] [ILMNRcht]*[ELSbcekmnt] | (cd $(distdir) && tar -x)
513+
@if [ -z "$(distdir)" ]; then echo "Please supply a distdir=DIR argument."; false; fi
514+
tar -c *.[ch15] [ILMNRchtv]*[ELSbcekmnth] | (cd $(distdir) && tar -x)
502515
+cd $(distdir) && $(MAKE) distclean
503516

504517
force:
@@ -507,7 +520,8 @@ force:
507520
.PHONY: all check clean distclean distdir force
508521
.PHONY: install install-pkgconfig installdirs lib-shared lib-static
509522
.PHONY: maintainer-clean mostlyclean plugins print-config print-version
510-
.PHONY: tags test testclean
523+
.PHONY: show-version tags test testclean
511524
.PHONY: clean-so install-so
512525
.PHONY: clean-cygdll install-cygdll
526+
.PHONY: clean-dll install-dll
513527
.PHONY: clean-dylib install-dylib

NEWS

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
Noteworthy changes in release 1.6 (28th September 2017)
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
* Fixed bug where iterators on CRAM files did not propagate error return
5+
values to the caller correctly. Thanks go to Chris Saunders.
6+
7+
* Overhauled Windows builds. Building with msys2/mingw64 now works
8+
correctly and passes all tests.
9+
10+
* More improvements to logging output (thanks again to Anders Kaplan).
11+
12+
* Return codes from sam_read1() when reading cram have been made
13+
consistent with those returned when reading sam/bam. Thanks to
14+
Chris Saunders (#575).
15+
16+
* BGZF CRC32 checksums are now always verified.
17+
18+
* It's now possible to set nthreads = 1 for cram files.
19+
20+
* hfile_libcurl has been modified to make it thread-safe. It's also
21+
better at handling web servers that do not honour byte range requests
22+
when attempting to seek - it now sets errno to ESPIPE and keeps
23+
the existing connection open so callers can revert to streaming mode
24+
it they want to.
25+
26+
* hfile_s3 now recalculates access tokens if they have become stale. This
27+
fixes a reported problem where authentication failed after a file
28+
had been in use for more than 15 minutes.
29+
30+
* Fixed bug where remote index fetches would fail to notice errors when
31+
writing files.
32+
33+
* bam_read1() now checks that the query sequence length derived from the
34+
CIGAR alignment matches the sequence length in the BAM record.
35+
136
Noteworthy changes in release 1.5 (21st June 2017)
237
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338

@@ -18,7 +53,7 @@ Noteworthy changes in release 1.4.1 (8th May 2017)
1853

1954
This is primarily a security bug fix update.
2055

21-
* Fixed SECURITY issue with buffer overruns with malicious data. (#514).
56+
* Fixed SECURITY (CVE-2017-1000206) issue with buffer overruns with malicious data. (#514).
2257

2358
* S3 support for non Amazon AWS endpoints. (#506)
2459

0 commit comments

Comments
 (0)