Adapt tests to zlib-1.2.11

This commit is contained in:
Petr Písař 2017-02-10 09:55:36 +01:00
parent 4890b78564
commit ccd8d520b4
3 changed files with 205 additions and 1 deletions

View File

@ -0,0 +1,94 @@
From b42f5c088158f473116d3aca2d050d4efb95b021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 7 Feb 2017 14:44:48 +0100
Subject: [PATCH] Adapt tests to zlib 1.2.11
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Since zlib-1.2.9 it's not safe to invoke deflateParams() when not all
input was consumed by deflate(). deflateParams() could return
Z_BUF_ERROR in some cases:
commit 7161ad76e2d0ac7de2a6235fcad3b9dfc99e9140
Author: Mark Adler <madler@alumni.caltech.edu>
Date: Tue Nov 22 23:29:19 2016 -0800
Assure that deflateParams() will not switch functions mid-block.
This alters the specification in zlib.h, so that deflateParams()
will not change any parameters if there is not enough output space
in the event that a block is emitted in order to allow switching
the compression function.
zlib documentation recommends two fixes:
To retry deflateParams() as it processes a piece of input underneath
until something else than Z_BUF_ERROR is returned. However this does
not work for me because then the compressed stream gets corrupted
and the subsequent inflate() returns a failure.
Another fix is to flush the deflated stream with Z_BLOCK just before
any deflateParams() call that follows unifinished deflate(). This
assures the new deflate options will be applied immediatelly on next
deflate() call. This fix works for me. Thus I implemented it in the
tests.
The new tests pass with zlib 1.2.8 as well as 1.2.11. 1.2.9 and 1.2.10
seems broken changing the deflate options was fixed in 1.2.11.
CPAN RT#119762
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
t/02zlib.t | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/t/02zlib.t b/t/02zlib.t
index 2c9aad6..50f6a82 100644
--- a/t/02zlib.t
+++ b/t/02zlib.t
@@ -24,13 +24,13 @@ BEGIN
my $count = 0 ;
if ($] < 5.005) {
- $count = 232 ;
+ $count = 236 ;
}
elsif ($] >= 5.006) {
- $count = 317 ;
+ $count = 320 ;
}
else {
- $count = 275 ;
+ $count = 278 ;
}
plan tests => $count + $extra;
@@ -537,6 +537,7 @@ SKIP:
$status = $x->deflate($hello, $Answer) ;
cmp_ok $status, '==', Z_OK ;
+ cmp_ok $x->flush($Answer, Z_BLOCK), '==', Z_OK ;
$input .= $hello;
# error cases
@@ -561,6 +562,7 @@ SKIP:
$status = $x->deflate($goodbye, $Answer) ;
cmp_ok $status, '==', Z_OK ;
+ cmp_ok $x->flush($Answer, Z_BLOCK), '==', Z_OK ;
$input .= $goodbye;
# change only Level
@@ -572,6 +574,7 @@ SKIP:
$status = $x->deflate($goodbye, $Answer) ;
cmp_ok $status, '==', Z_OK ;
+ cmp_ok $x->flush($Answer, Z_BLOCK), '==', Z_OK ;
$input .= $goodbye;
# change only Strategy
--
2.7.4

View File

@ -0,0 +1,95 @@
From a30130055928e5979c35aceee75cc3becfe3ad22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 7 Feb 2017 17:23:29 +0100
Subject: [PATCH] Adapt tests to zlib 1.2.11
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
CPAN RT#120134
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
t/cz-03zlib-v1.t | 13 +++++++++++--
t/cz-06gzsetp.t | 4 +++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/t/cz-03zlib-v1.t b/t/cz-03zlib-v1.t
index a85ed10..e070d46 100755
--- a/t/cz-03zlib-v1.t
+++ b/t/cz-03zlib-v1.t
@@ -23,10 +23,10 @@ BEGIN
my $count = 0 ;
if ($] < 5.005) {
- $count = 453 ;
+ $count = 456 ;
}
else {
- $count = 471 ;
+ $count = 474 ;
}
@@ -721,6 +721,9 @@ EOM
($Answer, $status) = $x->deflate($hello) ;
ok $status == Z_OK ;
+ ($X, $status) = $x->flush(Z_BLOCK) ;
+ ok $status == Z_OK ;
+ $Answer .= $X ;
$input .= $hello;
# error cases
@@ -747,6 +750,9 @@ EOM
($X, $status) = $x->deflate($goodbye) ;
ok $status == Z_OK ;
$Answer .= $X ;
+ ($X, $status) = $x->flush(Z_BLOCK) ;
+ ok $status == Z_OK ;
+ $Answer .= $X ;
$input .= $goodbye;
# change only Level
@@ -759,6 +765,9 @@ EOM
($X, $status) = $x->deflate($goodbye) ;
ok $status == Z_OK ;
$Answer .= $X ;
+ ($X, $status) = $x->flush(Z_BLOCK) ;
+ ok $status == Z_OK ;
+ $Answer .= $X ;
$input .= $goodbye;
# change only Strategy
diff --git a/t/cz-06gzsetp.t b/t/cz-06gzsetp.t
index b2cc687..45869a0 100644
--- a/t/cz-06gzsetp.t
+++ b/t/cz-06gzsetp.t
@@ -39,7 +39,7 @@ my $ver = Compress::Zlib::zlib_version();
plan skip_all => "gzsetparams needs zlib 1.0.6 or better. You have $ver\n"
if ZLIB_VERNUM() < 0x1060 ;
-plan tests => 51 + $extra ;
+plan tests => 55 + $extra ;
# Check zlib_version and ZLIB_VERSION are the same.
SKIP: {
@@ -65,6 +65,7 @@ SKIP: {
$input .= $hello;
is $x->gzwrite($hello), $len_hello, "gzwrite returned $len_hello" ;
+ cmp_ok $x->gzflush(Z_BLOCK), '==', Z_OK, "flush before gzsetparams is ok";
# Error cases
eval { $x->gzsetparams() };
@@ -120,6 +121,7 @@ foreach my $CompressClass ('IO::Compress::Gzip',
my $input .= $hello;
is $x->write($hello), $len_hello, "wrote $len_hello bytes" ;
+ ok $x->flush(Z_BLOCK), "flush before deflateParams is ok";
# Change both Level & Strategy
ok $x->deflateParams(Z_BEST_SPEED, Z_HUFFMAN_ONLY), "deflateParams ok";
--
2.7.4

View File

@ -28,7 +28,7 @@
Name: perl Name: perl
Version: %{perl_version} Version: %{perl_version}
# release number must be even higher, because dual-lived modules will be broken otherwise # release number must be even higher, because dual-lived modules will be broken otherwise
Release: 387%{?dist} Release: 388%{?dist}
Epoch: %{perl_epoch} Epoch: %{perl_epoch}
Summary: Practical Extraction and Report Language Summary: Practical Extraction and Report Language
Group: Development/Languages Group: Development/Languages
@ -272,6 +272,11 @@ Patch75: perl-5.24.1-permit-goto-at-top-level-of-multicalled-sub.patch
# Fix a heap overlow in parsing $#, RT#129274, in upstream after 5.25.9 # Fix a heap overlow in parsing $#, RT#129274, in upstream after 5.25.9
Patch76: perl-5.24.1-perl-129274-avoid-treating-the-in-as-a-comment-intro.patch Patch76: perl-5.24.1-perl-129274-avoid-treating-the-in-as-a-comment-intro.patch
# Adapt tests to zlib-1.2.11, bug #1420326, CPAN RT#119762,
# should be removed after fixing Compress-Raw-Zlib properly
Patch77: Compress-Raw-Zlib-2.071-Adapt-tests-to-zlib-1.2.11.patch
Patch78: IO-Compress-2.070-Adapt-tests-to-zlib-1.2.11.patch
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048 # Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
@ -2972,6 +2977,12 @@ Perl extension for Version Objects
%patch74 -p1 %patch74 -p1
%patch75 -p1 %patch75 -p1
%patch76 -p1 %patch76 -p1
pushd cpan/Compress-Raw-Zlib
%patch77 -p1
popd
pushd cpan/IO-Compress
%patch78 -p1
popd
%patch200 -p1 %patch200 -p1
%patch201 -p1 %patch201 -p1
@ -3036,6 +3047,7 @@ perl -x patchlevel.h \
'Fedora Patch74: Fix a memory leak in B::RHE->HASH method (RT#130504)' \ 'Fedora Patch74: Fix a memory leak in B::RHE->HASH method (RT#130504)' \
'Fedora Patch75: Fix parsing goto statements in multicalled subroutine (RT#113938)' \ 'Fedora Patch75: Fix parsing goto statements in multicalled subroutine (RT#113938)' \
'Fedora Patch76: Fix a heap overlow in parsing $# (RT#129274)' \ 'Fedora Patch76: Fix a heap overlow in parsing $# (RT#129274)' \
'Fedora Patch77: Adapt tests to zlib-1.2.11 (CPAN RT#119762)' \
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \ 'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \ 'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
%{nil} %{nil}
@ -5312,6 +5324,9 @@ popd
# Old changelog entries are preserved in CVS. # Old changelog entries are preserved in CVS.
%changelog %changelog
* Fri Feb 10 2017 Petr Pisar <ppisar@redhat.com> - 4:5.24.1-388
- Adapt tests to zlib-1.2.11 (bug #1420326)
* Thu Jan 26 2017 Petr Pisar <ppisar@redhat.com> - 4:5.24.1-387 * Thu Jan 26 2017 Petr Pisar <ppisar@redhat.com> - 4:5.24.1-387
- Fix UTF-8 string handling in & operator (RT#129287) - Fix UTF-8 string handling in & operator (RT#129287)
- Fix recreation of *:: (RT#129869) - Fix recreation of *:: (RT#129869)