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