]> granicus.if.org Git - apache/commitdiff
* Actually append new data to the validation buffer and do not overwrite old
authorRuediger Pluem <rpluem@apache.org>
Thu, 16 Nov 2006 20:30:25 +0000 (20:30 +0000)
committerRuediger Pluem <rpluem@apache.org>
Thu, 16 Nov 2006 20:30:25 +0000 (20:30 +0000)
  data already there by setting the correct offset for the target buffer.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@475915 13f79535-47bb-0310-9956-ffa450edef68

modules/filters/mod_deflate.c

index 450354e64a18745694eb329343e8f76420becffe..28d805ec7a8d1bc1ee9b5732319e845ee9c33303 100644 (file)
@@ -1144,20 +1144,24 @@ static apr_status_t inflate_out_filter(ap_filter_t *f,
                 copy_size = VALIDATION_SIZE - ctx->validation_buffer_length;
                 if (copy_size > ctx->stream.avail_in)
                     copy_size = ctx->stream.avail_in;
-                memcpy(ctx->validation_buffer, ctx->stream.next_in, copy_size);
-            } else {
+                memcpy(ctx->validation_buffer + ctx->validation_buffer_length,
+                       ctx->stream.next_in, copy_size);
+                /* Saved copy_size bytes */
+                ctx->stream.avail_in -= copy_size;
+            }
+            if (ctx->stream.avail_in) {
                 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                               "Zlib: %d bytes of garbage at the end of "
                               "compressed stream.", ctx->stream.avail_in);
+                /*
+                 * There is nothing worth consuming for zlib left, because it is
+                 * either garbage data or the data has been copied to the
+                 * validation buffer (processing validation data is no business
+                 * for zlib). So set ctx->stream.avail_in to zero to indicate
+                 * this to the following while loop.
+                 */
+                ctx->stream.avail_in = 0;
             }
-            /*
-             * There is nothing worth consuming for zlib left, because it is
-             * either garbage data or the data has been copied to the
-             * validation buffer (processing validation data is no business for
-             * zlib). So set ctx->stream.avail_in to zero to indicate this to
-             * the following while loop.
-             */
-            ctx->stream.avail_in = 0;
         }
 
         zRC = Z_OK;