New upstream version 4.017+ds
authorgregor herrmann <gregoa@debian.org>
Fri, 10 Jul 2020 16:36:05 +0000 (18:36 +0200)
committergregor herrmann <gregoa@debian.org>
Fri, 10 Jul 2020 16:36:05 +0000 (18:36 +0200)
Changes
META.json
META.yml
Makefile.PL
author_tools/hobodecoder.pl
lib/Sereal/Encoder.pm
lib/Sereal/Encoder/Constants.pm
srl_reader_decompress.h

diff --git a/Changes b/Changes
index 2f74359a53248778db736f5f607c15e093cfc720..4360d3f7756b4669da4c507bbbeb9ea9cd007ea6 100644 (file)
--- a/Changes
+++ b/Changes
@@ -5,6 +5,15 @@ Revision history for Perl extension Sereal-Encoder
 *          of the decoder before upgrading to version 4 of the *
 *          encoder!                                            *
 ****************************************************************
+4.017 Thurs July 9, 2020
+    * The build fixes in 4.016 didn't work correctly, this should fix them.
+
+4.016 Thurs July 9, 2020
+    * Fix some dependency issues in build process
+
+4.015 Weds  July 8, 2020
+    * Build fixes (missing dependency)
+
 4.014 Thurs June 11, 2020
     * Fix build issue on non-win32 platforms.
     * Update zstd to 1.4.5
index f440fe449af71b9eb973691f0decc7324de43c2b..83345e39b7cd6a3867b0b5eda7760fe31b47f80f 100644 (file)
--- a/META.json
+++ b/META.json
@@ -4,7 +4,7 @@
       "Steffen Mueller <smueller@cpan.org>, Yves Orton <yves@cpan.org>"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 7.36, CPAN::Meta::Converter version 2.150010",
+   "generated_by" : "ExtUtils::MakeMaker version 7.46, CPAN::Meta::Converter version 2.150010",
    "license" : [
       "perl_5"
    ],
@@ -24,7 +24,8 @@
          "requires" : {
             "ExtUtils::ParseXS" : "2.21",
             "File::Find" : "0",
-            "File::Path" : "0"
+            "File::Path" : "0",
+            "Test::LongString" : "0"
          }
       },
       "configure" : {
@@ -62,6 +63,6 @@
          "url" : "git://github.com/Sereal/Sereal.git"
       }
    },
-   "version" : "4.014",
+   "version" : "4.017",
    "x_serialization_backend" : "JSON::PP version 2.27400"
 }
index 39b81caa045ff2a00acad2b05765f98a660ec9e4..2ffbf01a8edcdd638356e92380676404cde6d694 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -18,7 +18,7 @@ build_requires:
 configure_requires:
   ExtUtils::MakeMaker: '7.0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.36, CPAN::Meta::Converter version 2.150010'
+generated_by: 'ExtUtils::MakeMaker version 7.46, CPAN::Meta::Converter version 2.150010'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -34,5 +34,5 @@ requires:
 resources:
   bugtracker: https://github.com/Sereal/Sereal/issues
   repository: git://github.com/Sereal/Sereal.git
-version: '4.014'
-x_serialization_backend: 'CPAN::Meta::YAML version 0.011'
+version: '4.017'
+x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
index 2d365a058b10309e776f48d45417e9060551e5b0..d859b46a0f04391a87b67eed0a9342525b92c348 100644 (file)
@@ -76,6 +76,7 @@ inc::Sereal::BuildTools::WriteMakefile(
         'File::Find'        => 0,
         'File::Path'        => 0,
         'ExtUtils::ParseXS' => '2.21',
+        'Test::LongString'  => '0',
     },
     CONFIGURE_REQUIRES => {
         'ExtUtils::MakeMaker' => '7.0',
index eaaa079ee199added6ecc27c15a3d58f05ca89b2..77675c667997c0ecec7a0ddc087fd84a8af4b83c 100644 (file)
@@ -136,7 +136,7 @@ sub parse_long_double {
     return unpack( "D", $v );
 }
 
-my $fmt1= "%06u/%06u: %02x%1s %03s %s";
+my $fmt1= "%06d/%06d: %02x%1s %03s %s";
 my $fmt2= "%-6s %-6s  %-2s%1s %-3s %s";
 my $lead_items= 5;    # 1 less than the fmt2
 
@@ -229,7 +229,8 @@ sub parse_sv {
         parse_sv($ind);
     }
     elsif ( $o == SRL_HDR_PAD ) {
-        printf "PAD\n";
+        printf "[PAD]\n";
+        parse_sv($ind);
     }
     elsif ( $o == SRL_HDR_ALIAS ) {
         my $ofs= varint();
@@ -354,7 +355,9 @@ close $fh;
 
 print "\n\nTotal length: " . length($data) . "\n\n";
 
-parse_header();
 while ( length $data ) {
+    parse_header();
+    print "--- End header\n";
     $done= parse_sv("");
+    print "--- End Document\n";
 }
index 1f06614bfdb6a7cbf7806a650795352af6d1e438..3b78213420e7c31cf6902b68683a2d17325ccf81 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 use Carp qw/croak/;
 use XSLoader;
 
-our $VERSION= '4.014'; # Don't forget to update the TestCompat set for testing against installed decoders!
+our $VERSION= '4.017'; # Don't forget to update the TestCompat set for testing against installed decoders!
 our $XS_VERSION= $VERSION; $VERSION= eval $VERSION;
 
 # not for public consumption, just for testing.
@@ -537,7 +537,7 @@ in both time and space efficiency with the best alternatives.
 This mechanism is enabled using the C<freeze_callbacks> option of the encoder.
 It is inspired by the equivalent mechanism in L<CBOR::XS> and differs only
 in one minor detail, explained below. The general mechanism is documented
-in the I<A GENERIC OBJECT SERIALIATION PROTOCOL> section of L<Types::Serializer>.
+in the I<A GENERIC OBJECT SERIALIATION PROTOCOL> section of L<Types::Serialiser>.
 Similar to CBOR using C<CBOR>, Sereal uses the string C<Sereal> as a serializer
 identifier for the callbacks.
 
index d3f2b4d7b746c4b0e84b9985991976efa11a8416..3091687692381e9eb52bab6bb6aa0e83aa5a2be0 100644 (file)
@@ -4,7 +4,7 @@ use warnings;
 require Exporter;
 our @ISA= qw(Exporter);
 
-our $VERSION= '4.014'; # Don't forget to update the TestCompat set for testing against installed encoders!
+our $VERSION= '4.017'; # Don't forget to update the TestCompat set for testing against installed encoders!
 
 our ( @EXPORT_OK, %DEFINE, %TAG_INFO_HASH, @TAG_INFO_ARRAY );
 
index 1a1820cfb944c3384a7f030248f229aab9306d4b..de68b0f15da5511ac0cf7feb8cf1545709c522b9 100644 (file)
 SRL_STATIC_INLINE SV *
 srl_realloc_empty_buffer(pTHX_ srl_reader_buffer_t *buf,
                          const STRLEN header_len,
-                         const STRLEN body_len)
+                         const STRLEN body_len,
+                         const STRLEN compressed_len,
+                         char *compression_type,
+                         size_t max_uncompressed_size)
 {
     SV *b_sv;
     srl_reader_char_ptr b;
 
+    /* Sereal::Merger & Sereal::Path::Iterator do not have this option yet */
+    if ((max_uncompressed_size != 0) && (body_len > max_uncompressed_size))
+        croak("The expected uncompressed size is larger than the allowed maximum size");
+
     /* Let perl clean this up. Yes, it's not the most efficient thing
      * ever, but it's just one mortal per full decompression, so not
      * a bottle-neck. */
-    b_sv = sv_2mortal( newSV(header_len + body_len + 1 ));
+    if (0) {
+        b_sv = sv_2mortal( newSV(header_len + body_len + 1 ));
+    } else {
+        STRLEN total_requested= header_len + body_len + 1;
+        char *tmp_buf;
+
+        if (total_requested < body_len)
+            croak("Decompressed buffer is impossibly large. Refusing to decode.");
+
+        tmp_buf= Perl_malloc(total_requested); /* perl well defined malloc wrapper */
+
+        if (!tmp_buf)
+            croak("Insufficient memory to '%s' decompress. Size compressed=%"UVuf" uncompressed=%"UVuf,
+                compression_type, compressed_len, total_requested );
+
+        b_sv= sv_newmortal();
+        sv_upgrade(b_sv,SVt_PV);
+        SvPVX(b_sv)= tmp_buf;
+        SvPOK_on(b_sv);
+        SvCUR(b_sv)= header_len + body_len;
+        SvLEN(b_sv)= total_requested;
+    }
     b = (srl_reader_char_ptr) SvPVX(b_sv);
 
     buf->start = b;
@@ -75,7 +103,7 @@ srl_realloc_empty_buffer(pTHX_ srl_reader_buffer_t *buf,
  * The caller *MUST* call SRL_RDR_UPDATE_BODY_POS right after existing from this function. */
 
 SRL_STATIC_INLINE UV
-srl_decompress_body_snappy(pTHX_ srl_reader_buffer_t *buf, U8 encoding_flags, SV** buf_owner)
+srl_decompress_body_snappy(pTHX_ srl_reader_buffer_t *buf, U8 encoding_flags, SV** buf_owner, size_t max_uncompressed_size)
 {
     SV *buf_sv;
     int header_len;
@@ -101,7 +129,8 @@ srl_decompress_body_snappy(pTHX_ srl_reader_buffer_t *buf, U8 encoding_flags, SV
         SRL_RDR_ERROR(buf, "Invalid Snappy header in Snappy-compressed Sereal packet");
 
     /* Allocate output buffer and swap it into place within the bufoder. */
-    buf_sv = srl_realloc_empty_buffer(aTHX_ buf, sereal_header_len, dest_len);
+    buf_sv = srl_realloc_empty_buffer(aTHX_ buf, sereal_header_len, (STRLEN)dest_len,
+            compressed_packet_len, "Snappy", max_uncompressed_size);
     if (buf_owner) *buf_owner = buf_sv;
 
     decompress_ok = csnappy_decompress_noheader((char *)(old_pos + header_len),
@@ -125,7 +154,7 @@ srl_decompress_body_snappy(pTHX_ srl_reader_buffer_t *buf, U8 encoding_flags, SV
  * The caller *MUST* call SRL_RDR_UPDATE_BODY_POS right after existing from this function. */
 
 SRL_STATIC_INLINE UV
-srl_decompress_body_zlib(pTHX_ srl_reader_buffer_t *buf, SV** buf_owner)
+srl_decompress_body_zlib(pTHX_ srl_reader_buffer_t *buf, SV** buf_owner, size_t max_uncompressed_size)
 {
     SV *buf_sv;
     mz_ulong tmp;
@@ -144,7 +173,8 @@ srl_decompress_body_zlib(pTHX_ srl_reader_buffer_t *buf, SV** buf_owner)
     bytes_consumed = compressed_packet_len + SRL_RDR_POS_OFS(buf);
 
     /* Allocate output buffer and swap it into place within the decoder. */
-    buf_sv = srl_realloc_empty_buffer(aTHX_ buf, sereal_header_len, uncompressed_packet_len);
+    buf_sv = srl_realloc_empty_buffer(aTHX_ buf, sereal_header_len, uncompressed_packet_len,
+            compressed_packet_len, "ZLIB", max_uncompressed_size);
     if (buf_owner) *buf_owner = buf_sv;
 
     tmp = uncompressed_packet_len;
@@ -166,7 +196,7 @@ srl_decompress_body_zlib(pTHX_ srl_reader_buffer_t *buf, SV** buf_owner)
  * SRL_RDR_UPDATE_BODY_POS right after existing from this function. */
 
 SRL_STATIC_INLINE UV
-srl_decompress_body_zstd(pTHX_ srl_reader_buffer_t *buf, SV** buf_owner)
+srl_decompress_body_zstd(pTHX_ srl_reader_buffer_t *buf, SV** buf_owner, size_t max_uncompressed_size)
 {
     SV *buf_sv;
     UV bytes_consumed;
@@ -187,7 +217,8 @@ srl_decompress_body_zstd(pTHX_ srl_reader_buffer_t *buf, SV** buf_owner)
         SRL_RDR_ERROR(buf, "Invalid zstd packet with unknown uncompressed size");
 
     /* Allocate output buffer and swap it into place within the decoder. */
-    buf_sv = srl_realloc_empty_buffer(aTHX_ buf, sereal_header_len, (STRLEN) uncompressed_packet_len);
+    buf_sv = srl_realloc_empty_buffer(aTHX_ buf, sereal_header_len, (STRLEN) uncompressed_packet_len,
+            compressed_packet_len, "zstd", max_uncompressed_size);
     if (buf_owner) *buf_owner = buf_sv;
 
     decompress_code = ZSTD_decompress((void *)buf->pos, (size_t) uncompressed_packet_len,