summaryrefslogtreecommitdiff
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2022-08-10 07:50:17 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2022-08-10 07:50:17 +0000
commitf8a7155a14ccf633fb5670278326f595dfa36af3 (patch)
treebed4f4b716961f90997917d8697a47fec826eb65 /gnu/usr.bin
parent108fad8aef421c2153724034a16ee417a7af4ee4 (diff)
Build the Compress::Raw::Zlib perl module with /usr/lib/libz
Two actively used copies of zlib in base are enough. This simplifies handling security fixes. Now that zlib.h r1.7 is reverted, zlib ffi works fine on 32-bit architectures. Compared with an earlier attempt in March, this disables the Z_SOLO build option (problem found by gkoehler) and fixes two regress tests to work with zlib 1.2.12. Corresponding upstream commits: https://github.com/pmqs/Compress-Raw-Zlib/commit/c44e0b732e214b7f77d42a3af6ae64e https://github.com/pmqs/Compress-Raw-Zlib/commit/f47ea5f36c40fe19efe404dd75fd790 ok bluhm
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/Makefile.PL86
-rw-r--r--gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/config.in6
-rwxr-xr-xgnu/usr.bin/perl/cpan/Compress-Raw-Zlib/t/02zlib.t148
3 files changed, 215 insertions, 25 deletions
diff --git a/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/Makefile.PL b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/Makefile.PL
index d141df42a0b..20c8cd01d0a 100644
--- a/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/Makefile.PL
+++ b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/Makefile.PL
@@ -1,11 +1,13 @@
#! perl -w
use strict ;
-require 5.004 ;
+require 5.006 ;
+use lib '.';
use private::MakeUtil;
use ExtUtils::MakeMaker 5.16 ;
use ExtUtils::Install (); # only needed to check for version
+use Config;
my $ZLIB_LIB ;
my $ZLIB_INCLUDE ;
@@ -14,6 +16,13 @@ my $OLD_ZLIB = '' ;
my $WALL = '' ;
my $GZIP_OS_CODE = -1 ;
my $USE_PPPORT_H = ($ENV{PERL_CORE}) ? '' : '-DUSE_PPPORT_H';
+my $OPTIMIZE = $Config{'optimize'};
+if ($Config{'gccversion'} and $OPTIMIZE =~ /-g (gdb)? 3/x) {
+ $OPTIMIZE =~ s/-g(gdb)?3/-g/g; # [88936] out of memory with -g3 since 2.062
+}
+
+# Windows uses a different name for the zlib library
+my $ZLIB_LIBRARY_NAME = $^O eq 'MSWin32' ? 'zlib' : 'z' ;
#$WALL = ' -pedantic ' if $Config{'cc'} =~ /gcc/ ;
#$WALL = ' -Wall -Wno-comment ' if $Config{'cc'} =~ /gcc/ ;
@@ -66,7 +75,7 @@ WriteMakefile(
NAME => 'Compress::Raw::Zlib',
VERSION_FROM => 'lib/Compress/Raw/Zlib.pm',
INC => "-I$ZLIB_INCLUDE" ,
- DEFINE => "$OLD_ZLIB $WALL -DGZIP_OS_CODE=$GZIP_OS_CODE $USE_PPPORT_H" ,
+ DEFINE => "-DNO_VIZ $OLD_ZLIB $WALL -DGZIP_OS_CODE=$GZIP_OS_CODE $USE_PPPORT_H" ,
XS => { 'Zlib.xs' => 'Zlib.c'},
'depend' => { 'Makefile' => 'config.in' },
'clean' => { FILES => '*.c constants.h constants.xs' },
@@ -79,16 +88,52 @@ WriteMakefile(
(
$BUILD_ZLIB
? zlib_files($ZLIB_LIB)
- : (LIBS => [ "-L$ZLIB_LIB -lz " ])
+ : (LIBS => [ "-L$ZLIB_LIB -l$ZLIB_LIBRARY_NAME " ])
+ ),
+ OPTIMIZE => $OPTIMIZE,
+
+ INSTALLDIRS => ($] >= 5.009 && $] < 5.011 ? 'perl' : 'site'),
+
+ ( eval { ExtUtils::MakeMaker->VERSION(6.46) }
+ ? ( META_MERGE => {
+
+ "meta-spec" => { version => 2 },
+
+ no_index => {
+ directory => [ 't', 'private' ],
+ },
+
+ resources => {
+
+ bugtracker => {
+ web => 'https://github.com/pmqs/Compress-Raw-Zlib/issues'
+ },
+
+ homepage => 'https://github.com/pmqs/Compress-Raw-Zlib',
+
+ repository => {
+ type => 'git',
+ url => 'git://github.com/pmqs/Compress-Raw-Zlib.git',
+ web => 'https://github.com/pmqs/Compress-Raw-Zlib',
+ },
+ },
+ }
+ )
+ : ()
),
-
- INSTALLDIRS => ($] >= 5.009 ? 'perl' : 'site'),
((ExtUtils::MakeMaker->VERSION() gt '6.30') ?
('LICENSE' => 'perl') : ()),
) ;
+sub version_Macro
+{
+ my $ver = shift ;
+
+ return [ "#if ZLIB_VERNUM >= 0x$ver\n", "#endif\n" ];
+}
+
my @names = qw(
DEF_WBITS
@@ -129,9 +174,13 @@ my @names = qw(
);
#ZLIB_VERNUM
+my %verSpecificNames = (
+ Z_TREES => '1240',
+);
+
if (eval {require ExtUtils::Constant; 1}) {
# Check the constants above all appear in @EXPORT in Zlib.pm
- my %names = map { $_, 1} @names, 'ZLIB_VERSION';
+ my %names = %verSpecificNames, map { $_, 1} @names, 'ZLIB_VERSION';
open F, "<lib/Compress/Raw/Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
while (<F>)
{
@@ -153,7 +202,13 @@ if (eval {require ExtUtils::Constant; 1}) {
"\t$missing\n" ;
}
- push @names, {name => 'ZLIB_VERSION', type => 'PV' };
+ push @names, { name => 'ZLIB_VERSION', type => 'PV' };
+
+ push @names, map { { name => $_,
+ macro => version_Macro $verSpecificNames{$_}
+ }
+ }
+ keys %verSpecificNames ;
ExtUtils::Constant::WriteConstants(
NAME => 'Zlib',
@@ -162,6 +217,7 @@ if (eval {require ExtUtils::Constant; 1}) {
XS_FILE => 'constants.xs',
);
+
}
else {
foreach my $name (qw( constants.h constants.xs ))
@@ -210,18 +266,26 @@ sub ParseCONFIG
die "The following keys are missing from $CONFIG [@missing]\n"
if @missing = keys %Parsed ;
- $ZLIB_INCLUDE = $ENV{'ZLIB_INCLUDE'} || $Info{'INCLUDE'} ;
- $ZLIB_LIB = $ENV{'ZLIB_LIB'} || $Info{'LIB'} ;
+ $ZLIB_INCLUDE = defined $ENV{'ZLIB_INCLUDE'}
+ ? $ENV{'ZLIB_INCLUDE'}
+ : $Info{'INCLUDE'} ;
+ $ZLIB_LIB = defined $ENV{'ZLIB_LIB'}
+ ?$ENV{'ZLIB_LIB'}
+ : $Info{'LIB'} ;
if ($^O eq 'VMS') {
$ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
$ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
}
- my $y = $ENV{'OLD_ZLIB'} || $Info{'OLD_ZLIB'} ;
+ my $y = defined $ENV{'OLD_ZLIB'}
+ ? $ENV{'OLD_ZLIB'}
+ : $Info{'OLD_ZLIB'} ;
$OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
- my $x = $ENV{'BUILD_ZLIB'} || $Info{'BUILD_ZLIB'} ;
+ my $x = defined $ENV{'BUILD_ZLIB'}
+ ? $ENV{'BUILD_ZLIB'}
+ : $Info{'BUILD_ZLIB'} ;
if ($x and $x =~ /^yes|on|true|1$/i ) {
diff --git a/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/config.in b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/config.in
index d6701ffb0cf..30d14a6b220 100644
--- a/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/config.in
+++ b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/config.in
@@ -16,9 +16,9 @@
# Setting the Gzip OS Code
#
-BUILD_ZLIB = True
-INCLUDE = ./zlib-src
-LIB = ./zlib-src
+BUILD_ZLIB = False
+INCLUDE = /usr/include
+LIB = /usr/lib
OLD_ZLIB = False
GZIP_OS_CODE = AUTO_DETECT
diff --git a/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/t/02zlib.t b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/t/02zlib.t
index f0548c912ef..3cc762ec9f2 100755
--- a/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/t/02zlib.t
+++ b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/t/02zlib.t
@@ -13,6 +13,7 @@ use bytes;
use Test::More ;
use CompTestUtils;
+use constant ZLIB_1_2_12_0 => 0x12C0;
BEGIN
{
@@ -24,13 +25,13 @@ BEGIN
my $count = 0 ;
if ($] < 5.005) {
- $count = 230 ;
+ $count = 237 ;
}
elsif ($] >= 5.006) {
- $count = 300 ;
+ $count = 325 ;
}
else {
- $count = 258 ;
+ $count = 280 ;
}
plan tests => $count + $extra;
@@ -39,6 +40,8 @@ BEGIN
}
+my $Zlib_ver = Compress::Raw::Zlib::zlib_version ;
+
my $hello = <<EOM ;
hello world
this is a test
@@ -47,8 +50,12 @@ EOM
my $len = length $hello ;
# Check zlib_version and ZLIB_VERSION are the same.
-is Compress::Raw::Zlib::zlib_version, ZLIB_VERSION,
- "ZLIB_VERSION matches Compress::Raw::Zlib::zlib_version" ;
+SKIP: {
+ skip "TEST_SKIP_VERSION_CHECK is set", 1
+ if $ENV{TEST_SKIP_VERSION_CHECK};
+ is Compress::Raw::Zlib::zlib_version, ZLIB_VERSION,
+ "ZLIB_VERSION matches Compress::Raw::Zlib::zlib_version" ;
+}
{
title "Error Cases" ;
@@ -424,9 +431,13 @@ for my $consume ( 0 .. 1)
}
+SKIP:
{
title 'inflateSync';
+ skip "inflateSync needs zlib 1.2.1 or better, you have $Zlib_ver", 22
+ if ZLIB_VERNUM() < 0x1210 ;
+
# create a deflate stream with flush points
my $hello = "I am a HAL 9000 computer" x 2001 ;
@@ -479,10 +490,18 @@ for my $consume ( 0 .. 1)
# print "x $status\n";
last if $status == Z_STREAM_END or $status != Z_OK ;
}
-
- cmp_ok $status, '==', Z_DATA_ERROR ;
- is $GOT, $goodbye ;
+ # Z_STREAM_END returned by 1.12.2, Z_DATA_ERROR for older zlib
+ if (ZLIB_VERNUM >= ZLIB_1_2_12_0)
+ {
+ cmp_ok $status, '==', Z_STREAM_END ;
+ }
+ else
+ {
+ cmp_ok $status, '==', Z_DATA_ERROR ;
+ }
+
+ is $GOT, $goodbye ;
# Check inflateSync leaves good data in buffer
my $rest = $Answer ;
@@ -504,7 +523,17 @@ for my $consume ( 0 .. 1)
is length($rest), $len2, "expected compressed output";
$GOT = '';
- cmp_ok $k->inflate($rest, $GOT), '==', Z_DATA_ERROR, "inflate returns Z_DATA_ERROR";
+ $status = $k->inflate($rest, $GOT);
+ # Z_STREAM_END returned by 1.12.2, Z_DATA_ERROR for older zlib
+ if (ZLIB_VERNUM >= ZLIB_1_2_12_0)
+ {
+ cmp_ok $status, '==', Z_STREAM_END ;
+ }
+ else
+ {
+ cmp_ok $status, '==', Z_DATA_ERROR ;
+ }
+
is $GOT, $goodbye ;
}
@@ -549,6 +578,13 @@ for my $consume ( 0 .. 1)
is $x->get_Level(), Z_BEST_SPEED;
is $x->get_Strategy(), Z_HUFFMAN_ONLY;
+ # change both Level & Strategy again without any calls to deflate
+ $status = $x->deflateParams(-Level => Z_DEFAULT_COMPRESSION, -Strategy => Z_DEFAULT_STRATEGY, -Bufsize => 1234) ;
+ cmp_ok $status, '==', Z_OK ;
+
+ is $x->get_Level(), Z_DEFAULT_COMPRESSION;
+ is $x->get_Strategy(), Z_DEFAULT_STRATEGY;
+
$status = $x->deflate($goodbye, $Answer) ;
cmp_ok $status, '==', Z_OK ;
$input .= $goodbye;
@@ -558,7 +594,7 @@ for my $consume ( 0 .. 1)
cmp_ok $status, '==', Z_OK ;
is $x->get_Level(), Z_NO_COMPRESSION;
- is $x->get_Strategy(), Z_HUFFMAN_ONLY;
+ is $x->get_Strategy(), Z_DEFAULT_STRATEGY;
$status = $x->deflate($goodbye, $Answer) ;
cmp_ok $status, '==', Z_OK ;
@@ -724,18 +760,26 @@ if ($] >= 5.005)
}
+SKIP:
{
+ skip "InflateScan needs zlib 1.2.1 or better, you have $Zlib_ver", 1
+ if ZLIB_VERNUM() < 0x1210 ;
+
# regression - check that resetLastBlockByte can cope with a NULL
# pointer.
Compress::Raw::Zlib::InflateScan->new->resetLastBlockByte(undef);
ok 1, "resetLastBlockByte(undef) is ok" ;
}
+SKIP:
{
title "gzip mode";
# ================
+ skip "gzip mode needs zlib 1.2.1 or better, you have $Zlib_ver", 13
+ if ZLIB_VERNUM() < 0x1210 ;
+
my $hello = "I am a HAL 9000 computer" ;
my @hello = split('', $hello) ;
my ($err, $x, $X, $status);
@@ -776,6 +820,7 @@ if ($] >= 5.005)
is $GOT, $hello, "uncompressed data matches ok" ;
}
+SKIP:
{
title "gzip error mode";
@@ -784,6 +829,9 @@ if ($] >= 5.005)
# then read with WANT_GZIP_OR_ZLIB - thi swill work
# ================
+ skip "gzip mode needs zlib 1.2.1 or better, you have $Zlib_ver", 12
+ if ZLIB_VERNUM() < 0x1210 ;
+
my $hello = "I am a HAL 9000 computer" ;
my ($err, $x, $X, $status);
@@ -822,14 +870,17 @@ if ($] >= 5.005)
is $GOT, $hello, "uncompressed data matches ok" ;
}
+SKIP:
{
-
title "gzip/zlib error mode";
# Create zlib -
# read with no WANT_GZIP windowbits setting - this will fail
# then read with WANT_GZIP_OR_ZLIB - thi swill work
# ================
+ skip "gzip mode needs zlib 1.2.1 or better, you have $Zlib_ver", 12
+ if ZLIB_VERNUM() < 0x1210 ;
+
my $hello = "I am a HAL 9000 computer" ;
my ($err, $x, $X, $status);
@@ -867,6 +918,81 @@ if ($] >= 5.005)
is $GOT, $hello, "uncompressed data matches ok" ;
}
+{
+ title "zlibCompileFlags";
+
+ my $flags = Compress::Raw::Zlib::zlibCompileFlags;
+
+ if (ZLIB_VERNUM() < 0x1210)
+ {
+ is $flags, 0, "zlibCompileFlags == 0 if < 1.2.1";
+ }
+ else
+ {
+ ok $flags, "zlibCompileFlags != 0 if < 1.2.1";
+ }
+}
+
+{
+ title "repeated calls to flush after some compression";
+
+ my $hello = "I am a HAL 9000 computer" ;
+ my ($err, $x, $X, $status);
+
+ ok( ($x, $err) = new Compress::Raw::Zlib::Deflate ( ), "Create deflate object" );
+ isa_ok $x, "Compress::Raw::Zlib::deflateStream" ;
+ cmp_ok $err, '==', Z_OK, "status is Z_OK" ;
+
+ $status = $x->deflate($hello, $X) ;
+ cmp_ok $status, '==', Z_OK, "deflate returned Z_OK" ;
+
+ cmp_ok $x->flush($X, Z_SYNC_FLUSH), '==', Z_OK, "flush returned Z_OK" ;
+ cmp_ok $x->flush($X, Z_SYNC_FLUSH), '==', Z_OK, "second flush returned Z_OK" ;
+ is $X, "", "no output from second flush";
+}
+
+{
+ title "repeated calls to flush - no compression";
+
+ my $hello = "I am a HAL 9000 computer" ;
+ my ($err, $x, $X, $status);
+
+ ok( ($x, $err) = new Compress::Raw::Zlib::Deflate ( ), "Create deflate object" );
+ isa_ok $x, "Compress::Raw::Zlib::deflateStream" ;
+ cmp_ok $err, '==', Z_OK, "status is Z_OK" ;
+
+ cmp_ok $x->flush($X, Z_SYNC_FLUSH), '==', Z_OK, "flush returned Z_OK" ;
+ cmp_ok $x->flush($X, Z_SYNC_FLUSH), '==', Z_OK, "second flush returned Z_OK" ;
+ is $X, "", "no output from second flush";
+}
+
+{
+ title "crc32";
+
+ is eval('Compress::Raw::Zlib::crc32("A" x 0x100, 0, 0x100); 0x1234'), 0x1234;
+ is $@, '';
+
+ is eval('Compress::Raw::Zlib::crc32("A" x 0x100, 0, 0x101); 0x1234'), undef;
+ like $@, mkErr("^Offset out of range in Compress::Raw::Zlib::crc32") ;
+
+}
+
+if (0)
+{
+ title "RT #122695: sync flush appending extra empty uncompressed block";
+
+ my $hello = "I am a HAL 9000 computer" ;
+ my ($err, $x, $X, $status);
+
+ ok( ($x, $err) = new Compress::Raw::Zlib::Deflate ( ), "Create deflate object" );
+ isa_ok $x, "Compress::Raw::Zlib::deflateStream" ;
+ cmp_ok $err, '==', Z_OK, "status is Z_OK" ;
+
+ cmp_ok $x->flush($X, Z_SYNC_FLUSH), '==', Z_OK, "flush returned Z_OK" ;
+ cmp_ok $x->flush($X, Z_SYNC_FLUSH), '==', Z_OK, "second flush returned Z_OK" ;
+ is $X, "", "no output from second flush";
+}
+
exit if $] < 5.006 ;
title 'Looping Append test with substr output - substr the end of the string';