summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorMatthieu Suiche <matt@msuiche.net>2008-07-10 09:31:43 +0000
committerStefan Metzmacher <metze@samba.org>2008-09-07 19:18:17 +0200
commit1825077840085e77b8190a3b6caaf127736ee183 (patch)
treec57284027a00b1abbcf2f2625704974fcfccc292 /source4/lib
parent14965b7260f74fe8c49ace21562d913d37d50063 (diff)
downloadsamba-1825077840085e77b8190a3b6caaf127736ee183.tar.gz
samba-1825077840085e77b8190a3b6caaf127736ee183.tar.bz2
samba-1825077840085e77b8190a3b6caaf127736ee183.zip
lzxpress: fix for decompression...
Signed-off-by: Stefan Metzmacher <metze@samba.org> (This used to be commit ee505df3742dac0af8eec8b9b27d1e1f5ef54ca9)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/compression/lzxpress.c32
-rw-r--r--source4/lib/compression/lzxpress.h6
2 files changed, 17 insertions, 21 deletions
diff --git a/source4/lib/compression/lzxpress.c b/source4/lib/compression/lzxpress.c
index 506305176f..9ce4eb1e8d 100644
--- a/source4/lib/compression/lzxpress.c
+++ b/source4/lib/compression/lzxpress.c
@@ -32,7 +32,6 @@
*
*/
-#include "includes.h"
#include "replace.h"
#include "lzxpress.h"
@@ -57,10 +56,10 @@
))
#endif
-static uint32_t xpress_decompress(uint8_t *input,
- uint32_t input_size,
- uint8_t *output,
- uint32_t output_size)
+ssize_t lzxpress_decompress(const uint8_t *input,
+ uint32_t input_size,
+ uint8_t *output,
+ uint32_t max_output_size)
{
uint32_t output_index, input_index;
uint32_t indicator, indicator_bit;
@@ -112,11 +111,11 @@ static uint32_t xpress_decompress(uint8_t *input,
if (length == 15) {
length = input[input_index];
input_index += sizeof(uint8_t);
- if (length == 255) {
- length = PULL_LE_UINT16(input, input_index);
- input_index += sizeof(uint16_t);
- length -= (15 + 7);
- }
+ if (length == 255) {
+ length = PULL_LE_UINT16(input, input_index);
+ input_index += sizeof(uint16_t);
+ length -= (15 + 7);
+ }
length += 15;
}
length += 7;
@@ -125,20 +124,15 @@ static uint32_t xpress_decompress(uint8_t *input,
length += 3;
do {
- if (output_index >= output_size) break;
+ if ((output_index >= max_output_size) || ((offset + 1) > output_index)) break;
+
output[output_index] = output[output_index - offset - 1];
+
output_index += sizeof(uint8_t);
length -= sizeof(uint8_t);
} while (length != 0);
}
-
- } while ((output_index < output_size) && (input_index < input_size));
+ } while ((output_index < max_output_size) && (input_index < (input_size)));
return output_index;
}
-
-uint32_t lzxpress_decompress(DATA_BLOB *inbuf,
- DATA_BLOB *outbuf)
-{
- return xpress_decompress(inbuf->data, inbuf->length, outbuf->data, outbuf->length);
-}
diff --git a/source4/lib/compression/lzxpress.h b/source4/lib/compression/lzxpress.h
index 4862fd2635..c81dda8f85 100644
--- a/source4/lib/compression/lzxpress.h
+++ b/source4/lib/compression/lzxpress.h
@@ -37,7 +37,9 @@
#define XPRESS_BLOCK_SIZE 0x10000
-uint32_t lzxpress_decompress(DATA_BLOB *inbuf,
- DATA_BLOB *outbuf);
+ssize_t lzxpress_decompress(const uint8_t *input,
+ uint32_t input_size,
+ uint8_t *output,
+ uint32_t max_output_size);
#endif /* _LZXPRESS_H */