aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2007-12-11 16:49:19 +0200
committerLasse Collin <lasse.collin@tukaani.org>2007-12-11 16:49:19 +0200
commit3e16d51dd645667b05ff826665b1fc353aa41cd9 (patch)
tree2ce26b05eacbec07557f3e4cbe0982dea05ec675 /src/liblzma/common
parentGet rid of no-NLS gnulib. I don't know how to get it (diff)
downloadxz-3e16d51dd645667b05ff826665b1fc353aa41cd9.tar.xz
Remove uncompressed size tracking from the filter encoders.
It's not strictly needed there, and just complicates the code. LZ encoder never even had this feature. The primary reason to have uncompressed size tracking in filter encoders was validating that the application doesn't give different amount of input that it had promised. A side effect was to validate internal workings of liblzma. Uncompressed size tracking is still present in the Block encoder. Maybe it should be added to LZMA_Alone and raw encoders too. It's simpler to have one coder just to validate the uncompressed size instead of having it in every filter.
Diffstat (limited to 'src/liblzma/common')
-rw-r--r--src/liblzma/common/copy_coder.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/liblzma/common/copy_coder.c b/src/liblzma/common/copy_coder.c
index 41f327d1..0bd674f6 100644
--- a/src/liblzma/common/copy_coder.c
+++ b/src/liblzma/common/copy_coder.c
@@ -42,33 +42,12 @@ copy_encode(lzma_coder *coder, lzma_allocator *allocator,
in, in_pos, in_size, out, out_pos, out_size,
action);
- // If we get here, we are the last filter in the chain.
- assert(coder->uncompressed_size <= LZMA_VLI_VALUE_MAX);
-
- const size_t in_avail = in_size - *in_pos;
-
- // Check that we don't have too much input.
- if ((lzma_vli)(in_avail) > coder->uncompressed_size)
- return LZMA_DATA_ERROR;
-
- // Check that once LZMA_FINISH has been given, the amount of input
- // matches uncompressed_size, which is always known.
- if (action == LZMA_FINISH
- && coder->uncompressed_size != (lzma_vli)(in_avail))
- return LZMA_DATA_ERROR;
-
// We are the last coder in the chain.
// Just copy as much data as possible.
- const size_t in_used = bufcpy(
- in, in_pos, in_size, out, out_pos, out_size);
-
- // Update uncompressed_size if it is known.
- if (coder->uncompressed_size != LZMA_VLI_VALUE_UNKNOWN)
- coder->uncompressed_size -= in_used;
+ bufcpy(in, in_pos, in_size, out, out_pos, out_size);
// LZMA_SYNC_FLUSH and LZMA_FINISH are the same thing for us.
- if ((action != LZMA_RUN && *in_pos == in_size)
- || coder->uncompressed_size == 0)
+ if (action != LZMA_RUN && *in_pos == in_size)
return LZMA_STREAM_END;
return LZMA_OK;