aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/delta/delta_encoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-12-01 16:30:11 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-12-01 16:30:11 +0200
commit656ec87882ee74b192c4ea4a233a235eca7b04d4 (patch)
treeb0d2b9cc96ebedc03d2b8f88d452a84417b1933e /src/liblzma/delta/delta_encoder.c
parentAutomake includes the m4 directory, so don't add it in (diff)
downloadxz-656ec87882ee74b192c4ea4a233a235eca7b04d4.tar.xz
Added lzma_delta_coder_memusage() which also validates
the options.
Diffstat (limited to 'src/liblzma/delta/delta_encoder.c')
-rw-r--r--src/liblzma/delta/delta_encoder.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/liblzma/delta/delta_encoder.c b/src/liblzma/delta/delta_encoder.c
index bb772a6c..751aa92d 100644
--- a/src/liblzma/delta/delta_encoder.c
+++ b/src/liblzma/delta/delta_encoder.c
@@ -18,7 +18,7 @@
///////////////////////////////////////////////////////////////////////////////
#include "delta_encoder.h"
-#include "delta_common.h"
+#include "delta_private.h"
/// Copies and encodes the data at the same time. This is used when Delta
@@ -101,18 +101,12 @@ lzma_delta_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
lzma_delta_props_encode(const void *options, uint8_t *out)
{
- if (options == NULL)
+ // The caller must have already validated the options, so it's
+ // LZMA_PROG_ERROR if they are invalid.
+ if (lzma_delta_coder_memusage(options) == UINT64_MAX)
return LZMA_PROG_ERROR;
const lzma_options_delta *opt = options;
-
- // It's possible that newer liblzma versions will support larger
- // distance values.
- if (opt->type != LZMA_DELTA_TYPE_BYTE
- || opt->dist < LZMA_DELTA_DIST_MIN
- || opt->dist > LZMA_DELTA_DIST_MAX)
- return LZMA_OPTIONS_ERROR;
-
out[0] = opt->dist - LZMA_DELTA_DIST_MIN;
return LZMA_OK;