e16460
From 0452589669aed9ad06940de7c1620b340608868a Mon Sep 17 00:00:00 2001
e16460
From: Jitka Plesnikova <jplesnik@redhat.com>
e16460
Date: Mon, 1 Jun 2020 12:58:11 +0200
e16460
Subject: [PATCH] Upgrade to 3.21
e16460
e16460
---
e16460
 ChangeLog                      | 33 ++++++++++++++++++-
e16460
 MANIFEST                       |  3 +-
e16460
 Makefile.PL                    | 59 +++++++++++++---------------------
e16460
 __Storable__.pm => Storable.pm | 23 +++++++------
e16460
 Storable.pm.PL                 | 35 --------------------
e16460
 Storable.xs                    | 20 ++++++++----
e16460
 stacksize                      |  2 +-
e16460
 t/attach_errors.t              |  2 +-
e16460
 t/huge.t                       |  4 +--
e16460
 t/recurse.t                    |  4 +--
e16460
 t/regexp.t                     |  8 ++---
e16460
 11 files changed, 93 insertions(+), 100 deletions(-)
e16460
 rename __Storable__.pm => Storable.pm (99%)
e16460
 delete mode 100644 Storable.pm.PL
e16460
e16460
diff --git a/ChangeLog b/ChangeLog
e16460
index 0488199..bf35381 100644
e16460
--- a/ChangeLog
e16460
+++ b/ChangeLog
e16460
@@ -1,3 +1,34 @@
e16460
+2010-01-27 10:27:00 TonyC
e16460
+    version 3.20
e16460
+        * fix a format string and arguments for some debugging text
e16460
+        * linkify references to alternatives to Storable
e16460
+
e16460
+2020-01-27 11:01:00 TonyC
e16460
+    version 3.19
e16460
+        * add casts to match some I32 parameters to "%d" formats (#17339)
e16460
+        * fix dependencies in Makefile.PL -> META (#17422)
e16460
+        * make use of note() optional, this requires a newer version of
e16460
+          Test::More and there's a circular dependency between later
e16460
+          versions of Test::More and Storable  (#17422)
e16460
+
e16460
+2019-11-19 07:59:39 TonyC
e16460
+    version 3.18
e16460
+        * update bug tracker to point at github (#17298)
e16460
+        * disallow vstring magic strings over 2GB-1 (#17306)
e16460
+        * mark some ASCII dependent tests as ASCII platform only
e16460
+
e16460
+2019-08-08 11:48:00 TonyC
e16460
+    version 3.17
e16460
+        * correct a data type to ensure the check for too large results from
e16460
+	  STORABLE_freeze() are detected correctly (detected by Coverity)
e16460
+	* removed remains of stack size detection from the build process.
e16460
+	* moved CAN_FLOCK detection into XS to simplify the build process.
e16460
+
e16460
+2019-06-11 10:43:00 TonyC
e16460
+    version 3.16
e16460
+        * (perl #134179) fix self-referencing structures that include regexps
e16460
+        * bless regexps to preserve bless qr//, "Foo"
e16460
+
e16460
 2019-04-23 16:00:00 xsawyerx
e16460
     version 3.15
e16460
     * Fix leaking.
e16460
@@ -341,7 +372,7 @@ Sat Mar 13 20:11:03 GMT 2004   Nicholas Clark <nick@ccl4.org>
e16460
     Version 2.11
e16460
 
e16460
         1. Storing restricted hashes in canonical order would SEGV. Fixed.
e16460
-        2. It was impossible to retrieve references to PL_sv_no and and
e16460
+        2. It was impossible to retrieve references to PL_sv_no and
e16460
            PL_sv_undef from STORABLE_thaw hooks.
e16460
         3. restrict.t was failing on 5.8.0, due to 5.8.0's unique
e16460
            implementation of restricted hashes using PL_sv_undef
e16460
diff --git a/MANIFEST b/MANIFEST
e16460
index d30b94e..5e382d9 100644
e16460
--- a/MANIFEST
e16460
+++ b/MANIFEST
e16460
@@ -1,4 +1,3 @@
e16460
-__Storable__.pm
e16460
 ChangeLog
e16460
 hints/gnukfreebsd.pl
e16460
 hints/gnuknetbsd.pl
e16460
@@ -11,7 +10,7 @@ META.yml			Module meta-data (added by MakeMaker)
e16460
 ppport.h
e16460
 README
e16460
 stacksize
e16460
-Storable.pm.PL
e16460
+Storable.pm
e16460
 Storable.xs
e16460
 t/attach.t
e16460
 t/attach_errors.t
e16460
diff --git a/Makefile.PL b/Makefile.PL
e16460
index 4a39125..e03e141 100644
e16460
--- a/Makefile.PL
e16460
+++ b/Makefile.PL
e16460
@@ -10,43 +10,48 @@ use strict;
e16460
 use warnings;
e16460
 use ExtUtils::MakeMaker 6.31;
e16460
 use Config;
e16460
-use File::Copy qw(move copy);
e16460
-use File::Spec;
e16460
-
e16460
-my $pm = { 'Storable.pm' => '$(INST_ARCHLIB)/Storable.pm' };
e16460
 
e16460
 WriteMakefile(
e16460
     NAME                => 'Storable',
e16460
     AUTHOR              => 'Perl 5 Porters',
e16460
     LICENSE             => 'perl',
e16460
     DISTNAME            => "Storable",
e16460
-# We now ship this in t/
e16460
-#    PREREQ_PM           => { 'Test::More' => '0.41' },
e16460
-    PL_FILES        => { }, # prevent default behaviour
e16460
-    PM              => $pm,
e16460
-    PREREQ_PM           => { XSLoader => 0 },
e16460
+    PREREQ_PM           =>
e16460
+      {
e16460
+          XSLoader => 0,
e16460
+      },
e16460
+    ( $ExtUtils::MakeMaker::VERSION >= 6.64 ?
e16460
+        (
e16460
+            CONFIGURE_REQUIRES => {
e16460
+                'ExtUtils::MakeMaker' => '6.31',
e16460
+            },
e16460
+            BUILD_REQUIRES => {
e16460
+                'ExtUtils::MakeMaker' => '6.31',
e16460
+            },
e16460
+            TEST_REQUIRES => {
e16460
+                'Test::More' => '0.41',
e16460
+            },
e16460
+           )
e16460
+        : () ),
e16460
     INSTALLDIRS => ($] >= 5.007 && $] < 5.012) ? 'perl' : 'site',
e16460
-    VERSION_FROM    => '__Storable__.pm',
e16460
-    ABSTRACT_FROM   => '__Storable__.pm',
e16460
+    VERSION_FROM    => 'Storable.pm',
e16460
+    ABSTRACT_FROM   => 'Storable.pm',
e16460
     ($ExtUtils::MakeMaker::VERSION > 6.45 ?
e16460
      (META_MERGE        => { resources =>
e16460
-                               { bugtracker => 'http://rt.perl.org/perlbug/' },
e16460
+                               { bugtracker => 'https://github.com/Perl/perl5/issues' },
e16460
                             provides    => {
e16460
                                 'Storable'  => {
e16460
-                                    file        => '__Storable__.pm',
e16460
-                                    version     => MM->parse_version('__Storable__.pm'),
e16460
+                                    file        => 'Storable.pm',
e16460
+                                    version     => MM->parse_version('Storable.pm'),
e16460
                                 },
e16460
                             },
e16460
 
e16460
                            },
e16460
     ) : ()),
e16460
     dist                => { SUFFIX => 'gz', COMPRESS => 'gzip -f' },
e16460
-    clean               => { FILES => 'Storable-* Storable.pm lib' },
e16460
+    clean               => { FILES => 'Storable-*' },
e16460
 );
e16460
 
e16460
-# Unlink the .pm file included with the distribution
e16460
-1 while unlink "Storable.pm";
e16460
-
e16460
 my $ivtype = $Config{ivtype};
e16460
 
e16460
 # I don't know if the VMS folks ever supported long long on 5.6.x
e16460
@@ -67,16 +72,8 @@ in the Storable documentation for instructions on how to read your data.
e16460
 EOM
e16460
 }
e16460
 
e16460
-# compute the maximum stacksize, before and after linking
e16460
 package MY;
e16460
 
e16460
-# FORCE finish of INST_DYNAMIC, avoid loading the old Storable (failed XS_VERSION check)
e16460
-sub xlinkext {
e16460
-    my $s = shift->SUPER::linkext(@_);
e16460
-    $s =~ s|( :: .*)| $1 FORCE stacksize|;
e16460
-    $s
e16460
-}
e16460
-
e16460
 sub depend {
e16460
     "
e16460
 
e16460
@@ -87,13 +84,3 @@ release : dist
e16460
 	git push --tags
e16460
 "
e16460
 }
e16460
-
e16460
-sub postamble {
e16460
-'
e16460
-all :: Storable.pm
e16460
-	$(NOECHO) $(NOOP)
e16460
-
e16460
-Storable.pm :: Storable.pm.PL __Storable__.pm
e16460
-	$(PERLRUN) Storable.pm.PL
e16460
-'
e16460
-}
e16460
diff --git a/__Storable__.pm b/Storable.pm
e16460
similarity index 99%
e16460
rename from __Storable__.pm
e16460
rename to Storable.pm
e16460
index 9237371..1a750f1 100644
e16460
--- a/__Storable__.pm
e16460
+++ b/Storable.pm
e16460
@@ -8,7 +8,7 @@
e16460
 #  in the README file that comes with the distribution.
e16460
 #
e16460
 
e16460
-require XSLoader;
e16460
+BEGIN { require XSLoader }
e16460
 require Exporter;
e16460
 package Storable;
e16460
 
e16460
@@ -27,7 +27,9 @@ our @EXPORT_OK = qw(
e16460
 
e16460
 our ($canonical, $forgive_me);
e16460
 
e16460
-our $VERSION = '3.15';
e16460
+BEGIN {
e16460
+  our $VERSION = '3.21';
e16460
+}
e16460
 
e16460
 our $recursion_limit;
e16460
 our $recursion_limit_hash;
e16460
@@ -104,14 +106,12 @@ $Storable::flags = FLAGS_COMPAT;
e16460
 $Storable::downgrade_restricted = 1;
e16460
 $Storable::accept_future_minor = 1;
e16460
 
e16460
-XSLoader::load('Storable');
e16460
+BEGIN { XSLoader::load('Storable') };
e16460
 
e16460
 #
e16460
 # Determine whether locking is possible, but only when needed.
e16460
 #
e16460
 
e16460
-sub CAN_FLOCK; # TEMPLATE - replaced by Storable.pm.PL
e16460
-
e16460
 sub show_file_magic {
e16460
     print <
e16460
 #
e16460
@@ -266,7 +266,7 @@ sub _store {
e16460
     local *FILE;
e16460
     if ($use_locking) {
e16460
         open(FILE, ">>", $file) || logcroak "can't write into $file: $!";
e16460
-        unless (&CAN_FLOCK) {
e16460
+        unless (CAN_FLOCK) {
e16460
             logcarp
e16460
               "Storable::lock_store: fcntl/flock emulation broken on $^O";
e16460
             return undef;
e16460
@@ -410,7 +410,7 @@ sub _retrieve {
e16460
     my $self;
e16460
     my $da = $@;			# Could be from exception handler
e16460
     if ($use_locking) {
e16460
-        unless (&CAN_FLOCK) {
e16460
+        unless (CAN_FLOCK) {
e16460
             logcarp
e16460
               "Storable::lock_store: fcntl/flock emulation broken on $^O";
e16460
             return undef;
e16460
@@ -986,6 +986,9 @@ modifying C<$Storable::recursion_limit> and
e16460
 C<$Storable::recursion_limit_hash> respectively.  Either can be set to
e16460
 C<-1> to prevent any depth checks, though this isn't recommended.
e16460
 
e16460
+If you want to test what the limits are, the F<stacksize> tool is
e16460
+included in the C<Storable> distribution.
e16460
+
e16460
 =item *
e16460
 
e16460
 You can create endless loops if the things you serialize via freeze()
e16460
@@ -1224,9 +1227,9 @@ See CVE-2015-1592 and its metasploit module.
e16460
 If your application requires accepting data from untrusted sources,
e16460
 you are best off with a less powerful and more-likely safe
e16460
 serialization format and implementation. If your data is sufficiently
e16460
-simple, Cpanel::JSON::XS, Data::MessagePack or Serial are the best
e16460
-choices and offers maximum interoperability, but note that Serial is
e16460
-unsafe by default.
e16460
+simple, L<Cpanel::JSON::XS>, L<Data::MessagePack> or L<Sereal> are the best
e16460
+choices and offer maximum interoperability, but note that Sereal is
e16460
+L<unsafe by default|Sereal::Decoder/ROBUSTNESS>.
e16460
 
e16460
 =head1 WARNING
e16460
 
e16460
diff --git a/Storable.pm.PL b/Storable.pm.PL
e16460
deleted file mode 100644
e16460
index df979c0..0000000
e16460
--- a/Storable.pm.PL
e16460
+++ /dev/null
e16460
@@ -1,35 +0,0 @@
e16460
-use strict;
e16460
-use warnings;
e16460
-
e16460
-use Config;
e16460
-
e16460
-my $template;
e16460
-{	# keep all the code in an external template to keep it easy to update
e16460
-	local $/;
e16460
-	open my $FROM, '<', '__Storable__.pm' or die $!;
e16460
-	$template = <$FROM>;
e16460
-	close $FROM or die $!;
e16460
-}
e16460
-
e16460
-sub CAN_FLOCK {
e16460
-	return
e16460
-		$Config{'d_flock'} ||
e16460
-		$Config{'d_fcntl_can_lock'} ||
e16460
-		$Config{'d_lockf'}
e16460
-		? 1 : 0;
e16460
-}
e16460
-
e16460
-my $CAN_FLOCK = CAN_FLOCK();
e16460
-
e16460
-# populate the sub and preserve it if used outside
e16460
-$template =~ s{^sub CAN_FLOCK;.*$}{sub CAN_FLOCK { ${CAN_FLOCK} } # computed by Storable.pm.PL}m;
e16460
-# alternatively we could remove the sub
e16460
-#$template =~ s{^sub CAN_FLOCK;.*$}{}m;
e16460
-# replace local function calls to hardcoded value
e16460
-$template =~ s{&CAN_FLOCK}{${CAN_FLOCK}}g;
e16460
-
e16460
-{
e16460
-	open my $OUT, '>', 'Storable.pm' or die $!;
e16460
-	print {$OUT} $template or die $!;
e16460
-	close $OUT or die $!;
e16460
-}
e16460
diff --git a/Storable.xs b/Storable.xs
e16460
index e1f0b88..4c4c268 100644
e16460
--- a/Storable.xs
e16460
+++ b/Storable.xs
e16460
@@ -104,6 +104,12 @@
e16460
 #  define strEQc(s,c) memEQ(s, ("" c ""), sizeof(c))
e16460
 #endif
e16460
 
e16460
+#if defined(HAS_FLOCK) || defined(FCNTL_CAN_LOCK) && defined(HAS_LOCKF)
e16460
+#define CAN_FLOCK &PL_sv_yes
e16460
+#else
e16460
+#define CAN_FLOCK &PL_sv_no
e16460
+#endif
e16460
+
e16460
 #ifdef DEBUGME
e16460
 
e16460
 #ifndef DASSERT
e16460
@@ -726,8 +732,8 @@ static stcxt_t *Context_ptr = NULL;
e16460
         STRLEN nsz = (STRLEN) round_mgrow((x)+msiz);            \
e16460
         STRLEN offset = mptr - mbase;                           \
e16460
         ASSERT(!cxt->membuf_ro, ("mbase is not read-only"));    \
e16460
-        TRACEME(("** extending mbase from %ld to %ld bytes (wants %ld new)", \
e16460
-                 (long)msiz, nsz, (long)(x)));                  \
e16460
+        TRACEME(("** extending mbase from %lu to %lu bytes (wants %lu new)", \
e16460
+                 (unsigned long)msiz, (unsigned long)nsz, (unsigned long)(x)));  \
e16460
         Renew(mbase, nsz, char);                                \
e16460
         msiz = nsz;                                             \
e16460
         mptr = mbase + offset;                                  \
e16460
@@ -3085,7 +3091,7 @@ static int store_hash(pTHX_ stcxt_t *cxt, HV *hv)
e16460
             len = HEK_LEN(hek);
e16460
             if (len == HEf_SVKEY) {
e16460
                 /* This is somewhat sick, but the internal APIs are
e16460
-                 * such that XS code could put one of these in in
e16460
+                 * such that XS code could put one of these in
e16460
                  * a regular hash.
e16460
                  * Maybe we should be capable of storing one if
e16460
                  * found.
e16460
@@ -3437,7 +3443,7 @@ static int get_regexp(pTHX_ stcxt_t *cxt, SV* sv, SV **re, SV **flags) {
e16460
     count = call_sv((SV*)cv, G_ARRAY);
e16460
     SPAGAIN;
e16460
     if (count < 2)
e16460
-      CROAK(("re::regexp_pattern returned only %d results", count));
e16460
+      CROAK(("re::regexp_pattern returned only %d results", (int)count));
e16460
     *flags = POPs;
e16460
     SvREFCNT_inc(*flags);
e16460
     *re = POPs;
e16460
@@ -5952,7 +5958,7 @@ static SV *retrieve_lvstring(pTHX_ stcxt_t *cxt, const char *cname)
e16460
     }
e16460
 
e16460
     New(10003, s, len+1, char);
e16460
-    SAFEPVREAD(s, len, s);
e16460
+    SAFEPVREAD(s, (I32)len, s);
e16460
 
e16460
     sv = retrieve(aTHX_ cxt, cname);
e16460
     if (!sv) {
e16460
@@ -6858,7 +6864,7 @@ static SV *retrieve_regexp(pTHX_ stcxt_t *cxt, const char *cname) {
e16460
     SPAGAIN;
e16460
 
e16460
     if (count != 1)
e16460
-        CROAK(("Bad count %d calling _make_re", count));
e16460
+        CROAK(("Bad count %d calling _make_re", (int)count));
e16460
 
e16460
     re_ref = POPs;
e16460
 
e16460
@@ -7807,6 +7813,8 @@ BOOT:
e16460
     newCONSTSUB(stash, "BIN_MINOR", newSViv(STORABLE_BIN_MINOR));
e16460
     newCONSTSUB(stash, "BIN_WRITE_MINOR", newSViv(STORABLE_BIN_WRITE_MINOR));
e16460
 
e16460
+    newCONSTSUB(stash, "CAN_FLOCK", CAN_FLOCK);
e16460
+
e16460
     init_perinterp(aTHX);
e16460
     gv_fetchpv("Storable::drop_utf8",   GV_ADDMULTI, SVt_PV);
e16460
 #ifdef DEBUGME
e16460
diff --git a/stacksize b/stacksize
e16460
index f93eccc..2896684 100644
e16460
--- a/stacksize
e16460
+++ b/stacksize
e16460
@@ -161,7 +161,7 @@ my $max_depth_hash = $n;
e16460
 # instead so a user setting of either variable more closely matches
e16460
 # the limits the use sees.
e16460
 
e16460
-# be fairly aggressive in trimming this, smoke testing showed several
e16460
+# be fairly aggressive in trimming this, smoke testing showed
e16460
 # several apparently random failures here, eg. working in one
e16460
 # configuration, but not in a very similar configuration.
e16460
 $max_depth = int(0.6 * $max_depth);
e16460
diff --git a/t/attach_errors.t b/t/attach_errors.t
e16460
index 0ed7c8d..e2be39d 100644
e16460
--- a/t/attach_errors.t
e16460
+++ b/t/attach_errors.t
e16460
@@ -94,7 +94,7 @@ use Storable ();
e16460
 # Error 2
e16460
 #
e16460
 # If, for some reason, a STORABLE_attach object is accidentally stored
e16460
-# with references, this should be checked and and error should be throw.
e16460
+# with references, this should be checked and an error should be thrown.
e16460
 
e16460
 
e16460
 
e16460
diff --git a/t/huge.t b/t/huge.t
e16460
index d28e238..09b173e 100644
e16460
--- a/t/huge.t
e16460
+++ b/t/huge.t
e16460
@@ -63,7 +63,7 @@ if ($Config{ptrsize} > 4 and !$has_too_many) {
e16460
           [ 'huge array',
e16460
             sub { my @x; $x[$huge] = undef; \@x } ];
e16460
     } else {
e16460
-        diag "skip huge array, need PERL_TEST_MEMORY >= 8";
e16460
+        diag "skip huge array, need PERL_TEST_MEMORY >= 55";
e16460
     }
e16460
 }
e16460
 
e16460
@@ -78,7 +78,7 @@ if (!$has_too_many) {
e16460
           ['huge hash',
e16460
            sub { my %x = (0 .. $huge); \%x } ];
e16460
     } else {
e16460
-        diag "skip huge hash, need PERL_TEST_MEMORY >= 16";
e16460
+        diag "skip huge hash, need PERL_TEST_MEMORY >= 96";
e16460
     }
e16460
 }
e16460
 
e16460
diff --git a/t/recurse.t b/t/recurse.t
e16460
index b5967a0..6f82169 100644
e16460
--- a/t/recurse.t
e16460
+++ b/t/recurse.t
e16460
@@ -347,7 +347,7 @@ sub MAX_DEPTH_HASH () { Storable::stack_depth_hash() }
e16460
 eval {
e16460
     my $t;
e16460
     $t = [$t] for 1 .. MAX_DEPTH*2;
e16460
-    note 'trying catching recursive aref stack overflow';
e16460
+    eval { note('trying catching recursive aref stack overflow') };
e16460
     dclone $t;
e16460
 };
e16460
 like $@, qr/Max\. recursion depth with nested structures exceeded/,
e16460
@@ -362,7 +362,7 @@ else {
e16460
         my $t;
e16460
         # 35.000 will cause appveyor 64bit windows to fail earlier
e16460
         $t = {1=>$t} for 1 .. MAX_DEPTH * 2;
e16460
-        note 'trying catching recursive href stack overflow';
e16460
+        eval { note('trying catching recursive href stack overflow') };
e16460
         dclone $t;
e16460
     };
e16460
     like $@, qr/Max\. recursion depth with nested structures exceeded/,
e16460
diff --git a/t/regexp.t b/t/regexp.t
e16460
index e7c6c7e..6c6b1d5 100644
e16460
--- a/t/regexp.t
e16460
+++ b/t/regexp.t
e16460
@@ -123,7 +123,7 @@ __DATA__
e16460
 A-; qr(\x2E) ; ".", !"a" ; \x2E - hex meta
e16460
 -; qr/\./ ; "." , !"a" ; \. - backslash meta
e16460
 8- ; qr/\x{100}/ ; "\x{100}" ; simple unicode
e16460
-12- ; qr/fss/i ; "f\xDF\x{101}" ; case insensive unicode promoted
e16460
-22-; qr/fss/ui ; "f\xDF" ; case insensitive unicode SS /iu
e16460
-22-; qr/fss/aai ; !"f\xDF" ; case insensitive unicode SS /iaa
e16460
-22-; qr/f\w/a ; "fo", !"f\xff" ; simple /a flag
e16460
+A12- ; qr/fss/i ; "f\xDF\x{101}" ; case insensive unicode promoted
e16460
+A22-; qr/fss/ui ; "f\xDF" ; case insensitive unicode SS /iu
e16460
+A22-; qr/fss/aai ; !"f\xDF" ; case insensitive unicode SS /iaa
e16460
+A22-; qr/f\w/a ; "fo", !"f\xff" ; simple /a flag
e16460
-- 
e16460
2.25.4
e16460