subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svn-r...@apache.org
Subject svn commit: r1541801 - in /subversion/branches/1.8.x: ./ STATUS subversion/tests/libsvn_subr/checksum-test.c subversion/tests/libsvn_subr/zlib.deflated
Date Thu, 14 Nov 2013 04:02:46 GMT
Author: svn-role
Date: Thu Nov 14 04:02:46 2013
New Revision: 1541801

URL: http://svn.apache.org/r1541801
Log:
Merge the r1537193 group from trunk:

 * r1537193, r1537221, r1540428
   Add test to verify if the used ZLib is affected by some block size bugs that
   affect our usage of serf.
   Justification:
     Most Windows binaries were affected by this bug and we should verify
     that we don't accidentally reintroduce this problem.
   Notes:
     This patch needs the source directory for obtaining its test data. The
     backport branch contains portions of r1537147 and r1537190 to enable
     this test.
   Branch: ^/subversion/branches/1.8.x-r1537193/
   Votes:
     +1: stefan2, rhuijben, ivan
     +1 (without r1540428): brane

Added:
    subversion/branches/1.8.x/subversion/tests/libsvn_subr/zlib.deflated
      - copied unchanged from r1537193, subversion/trunk/subversion/tests/libsvn_subr/zlib.deflated
Modified:
    subversion/branches/1.8.x/   (props changed)
    subversion/branches/1.8.x/STATUS
    subversion/branches/1.8.x/subversion/tests/libsvn_subr/checksum-test.c

Propchange: subversion/branches/1.8.x/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1537193,1537221,1540428

Modified: subversion/branches/1.8.x/STATUS
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x/STATUS?rev=1541801&r1=1541800&r2=1541801&view=diff
==============================================================================
--- subversion/branches/1.8.x/STATUS (original)
+++ subversion/branches/1.8.x/STATUS Thu Nov 14 04:02:46 2013
@@ -187,21 +187,6 @@ Veto-blocked changes:
 Approved changes:
 =================
 
- * r1537193, r1537221, r1540428
-   Add test to verify if the used ZLib is affected by some block size bugs that
-   affect our usage of serf.
-   Justification:
-     Most Windows binaries were affected by this bug and we should verify
-     that we don't accidentally reintroduce this problem.
-   Notes:
-     This patch needs the source directory for obtaining its test data. The
-     backport branch contains portions of r1537147 and r1537190 to enable
-     this test.
-   Branch: ^/subversion/branches/1.8.x-r1537193/
-   Votes:
-     +1: stefan2, rhuijben, ivan
-     +1 (without r1540428): brane
-
  * r1541432
    Fix potential crash in mod_authz_svn during startup if path specified
    by AuthzSVNAccessFile, AuthzSVNReposRelativeAccessFile, or 

Modified: subversion/branches/1.8.x/subversion/tests/libsvn_subr/checksum-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/tests/libsvn_subr/checksum-test.c?rev=1541801&r1=1541800&r2=1541801&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/tests/libsvn_subr/checksum-test.c (original)
+++ subversion/branches/1.8.x/subversion/tests/libsvn_subr/checksum-test.c Thu Nov 14 04:02:46
2013
@@ -23,7 +23,10 @@
 
 #include <apr_pools.h>
 
+#include <zlib.h>
+
 #include "svn_error.h"
+#include "svn_io.h"
 #include "private/svn_pseudo_md5.h"
 
 #include "../svn_test.h"
@@ -155,6 +158,87 @@ zero_match(apr_pool_t *pool)
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+zlib_expansion_test(const svn_test_opts_t *opts,
+                    apr_pool_t *pool)
+{
+  const char *data_path;
+  svn_stringbuf_t *deflated;
+  Byte dst_buffer[256 * 1024];
+  Byte *src_buffer;
+  apr_size_t sz;
+
+  data_path = svn_dirent_join(opts->srcdir, "zlib.deflated", pool);
+
+  SVN_ERR(svn_stringbuf_from_file2(&deflated, data_path, pool));
+  src_buffer = (Byte*)deflated->data;
+
+  /* Try to decompress the same data with different blocksizes */
+  for (sz = 1; sz < 256; sz++)
+    {
+      z_stream stream;
+      memset(&stream, 0, sizeof(stream));
+      inflateInit2(&stream, -15 /* DEFLATE_WINDOW_SIZE */);
+
+      stream.avail_in = sz;
+      stream.next_in = src_buffer;
+      stream.avail_out = sizeof(dst_buffer);
+      stream.next_out = dst_buffer;
+
+      do
+        {
+          int zr = inflate(&stream, Z_NO_FLUSH);
+
+          if (zr != Z_OK && zr != Z_STREAM_END)
+          {
+              return svn_error_createf(
+                          SVN_ERR_TEST_FAILED, NULL,
+                          "Failure decompressing with blocksize %d", (int)sz);
+          }
+          stream.avail_in += sz;
+      } while (stream.next_in + stream.avail_in  < src_buffer + deflated->len);
+
+      stream.avail_in = (src_buffer + deflated->len) - stream.next_in;
+
+      {
+          int zr = inflate(&stream, Z_NO_FLUSH);
+
+          if (zr != Z_STREAM_END)
+            {
+              return svn_error_createf(
+                        SVN_ERR_TEST_FAILED, NULL,
+                        "Final flush failed with blocksize %d", (int)sz);
+            }
+
+          zr = inflateEnd(&stream);
+
+          if (zr != Z_OK)
+            {
+              return svn_error_createf(
+                        SVN_ERR_TEST_FAILED, NULL,
+                        "End of stream handling failed with blocksize %d",
+                        (int)sz);
+            }
+      }
+
+      {
+          apr_uint32_t crc = crc32(0, dst_buffer, stream.total_out);
+
+          if (stream.total_out != 242014 || crc != 0x8f03d934)
+            {
+              return svn_error_createf(
+                  SVN_ERR_TEST_FAILED, NULL,
+                  "Decompressed data doesn't match expected size or crc with "
+                  "blocksize %d: Found crc32=0x%08x, size=%d.\n"
+                  "Verify your ZLib installation, as this should never happen",
+                  (int)sz, (unsigned)crc, (int)stream.total_out);
+            }
+      }
+  }
+
+  return SVN_NO_ERROR;
+}
+
 /* An array of all test functions */
 struct svn_test_descriptor_t test_funcs[] =
   {
@@ -167,5 +251,7 @@ struct svn_test_descriptor_t test_funcs[
                    "pseudo-md5 compatibility"),
     SVN_TEST_PASS2(zero_match,
                    "zero checksum matching"),
+    SVN_TEST_OPTS_PASS(zlib_expansion_test,
+                       "zlib expansion test (zlib regression)"),
     SVN_TEST_NULL
   };



Mime
View raw message