diff -Nru samtools-legacy-0.1.19+dfsg/debian/changelog samtools-legacy-0.1.19+dfsg/debian/changelog --- samtools-legacy-0.1.19+dfsg/debian/changelog 2022-01-18 18:49:14.000000000 +0100 +++ samtools-legacy-0.1.19+dfsg/debian/changelog 2022-08-01 19:03:43.000000000 +0200 @@ -1,3 +1,12 @@ +samtools-legacy (0.1.19+dfsg-5ubuntu1) kinetic; urgency=medium + + * Add backport of upstream commit 515f6df as + d/p/515f6df-Remove-compressBound-assertions-PR-1258.patch + in support of fixing 'zlib: compressBound() returns an incorrect result + on z15'. (LP: #1983255) + + -- Frank Heimes Mon, 01 Aug 2022 19:03:43 +0200 + samtools-legacy (0.1.19+dfsg-5) unstable; urgency=medium * Team upload. diff -Nru samtools-legacy-0.1.19+dfsg/debian/control samtools-legacy-0.1.19+dfsg/debian/control --- samtools-legacy-0.1.19+dfsg/debian/control 2022-01-18 18:49:14.000000000 +0100 +++ samtools-legacy-0.1.19+dfsg/debian/control 2022-08-01 19:03:43.000000000 +0200 @@ -1,5 +1,6 @@ Source: samtools-legacy -Maintainer: Debian Med Packaging Team +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian Med Packaging Team Uploaders: Charles Plessy Section: science Priority: optional diff -Nru samtools-legacy-0.1.19+dfsg/debian/patches/515f6df-Remove-compressBound-assertions.-PR-1258.patch samtools-legacy-0.1.19+dfsg/debian/patches/515f6df-Remove-compressBound-assertions.-PR-1258.patch --- samtools-legacy-0.1.19+dfsg/debian/patches/515f6df-Remove-compressBound-assertions.-PR-1258.patch 2022-01-18 18:49:14.000000000 +0100 +++ samtools-legacy-0.1.19+dfsg/debian/patches/515f6df-Remove-compressBound-assertions.-PR-1258.patch 2022-08-01 19:03:43.000000000 +0200 @@ -18,7 +18,7 @@ Fixes #1257 -Backported to fit the obviously outdated version of bgzf.c that is used +Backported to fit the outdated version of bgzf.c that is used in package samtools-legacy-0.1.19+dfsg. Origin: upstream/backport, https://github.com/samtools/htslib.git515f6df @@ -39,7 +39,7 @@ if (strchr(mode, 'r') || strchr(mode, 'R')) { _bgzf_file_t fpr; if ((fpr = _bgzf_open(path, "r")) == 0) return 0; -@@ -157,7 +324,6 @@ +@@ -157,7 +156,6 @@ BGZF *bgzf_dopen(int fd, const char *mode) { BGZF *fp = 0; @@ -47,27 +47,53 @@ if (strchr(mode, 'r') || strchr(mode, 'R')) { _bgzf_file_t fpr; if ((fpr = _bgzf_dopen(fd, "r")) == 0) return 0; -@@ -184,8 +184,22 @@ - zs.avail_in = slen; - zs.next_out = dst + BLOCK_HEADER_LENGTH; - zs.avail_out = *dlen - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH; -+ uncomp: - if (deflateInit2(&zs, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) return -1; // -15 to disable zlib header/footer +@@ -178,16 +176,39 @@ + z_stream zs; + uint8_t *dst = (uint8_t*)_dst; + +- // compress the body +- zs.zalloc = NULL; zs.zfree = NULL; +- zs.next_in = src; +- zs.avail_in = slen; +- zs.next_out = dst + BLOCK_HEADER_LENGTH; +- zs.avail_out = *dlen - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH; +- if (deflateInit2(&zs, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) return -1; // -15 to disable zlib header/footer - if (deflate(&zs, Z_FINISH) != Z_STREAM_END) return -1; -+ if ((ret = deflate(&zs, Z_FINISH)) != Z_STREAM_END) { -+ if (ret == Z_OK && zs.avail_out == 0) { +- if (deflateEnd(&zs) != Z_OK) return -1; +- *dlen = zs.total_out + BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH; ++ if (level == 0) { ++ uncomp: ++ // Uncompressed data ++ if (*dlen < slen+5 + BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH) return -1; ++ dst[BLOCK_HEADER_LENGTH] = 1; // BFINAL=1, BTYPE=00; see RFC1951 ++ memcpy(dst + BLOCK_HEADER_LENGTH+5, src, slen); ++ *dlen = slen+5 + BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH; ++ } else { ++ // compress the body ++ zs.zalloc = NULL; zs.zfree = NULL; ++ zs.next_in = src; ++ zs.avail_in = slen; ++ zs.next_out = dst + BLOCK_HEADER_LENGTH; ++ zs.avail_out = *dlen - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH; ++ int ret = deflateInit2(&zs, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); // -15 to disable zlib header/footer ++ if (ret != Z_OK) return -1; ++ if ((ret = deflate(&zs, Z_FINISH)) != Z_STREAM_END) { ++ if (ret == Z_OK && zs.avail_out == 0) { ++ deflateEnd(&zs); ++ goto uncomp; ++ } ++ return -1; ++ } ++ // If we used up the entire output buffer, then we either ran out of ++ // room or we *just* fitted, but either way we may as well store ++ // uncompressed for faster decode. ++ if (zs.avail_out == 0) { + deflateEnd(&zs); + goto uncomp; + } -+ return -1; -+ } -+ // If we used up the entire output buffer, then we either ran out of -+ // room or we *just* fitted, but either way we may as well store -+ // uncompressed for faster decode. -+ if (zs.avail_out == 0) { -+ deflateEnd(&zs); -+ goto uncomp; ++ if (deflateEnd(&zs) != Z_OK) return -1; ++ *dlen = zs.total_out + BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH; + } - if (deflateEnd(&zs) != Z_OK) return -1; - *dlen = zs.total_out + BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH; // write the header + memcpy(dst, g_magic, BLOCK_HEADER_LENGTH); // the last two bytes are a place holder for the length of the block + packInt16(&dst[16], *dlen - 1); // write the compressed length; -1 to fit 2 bytes