parent
f9f3fdfb1c
commit
ab713923a2
@ -1931,7 +1931,7 @@ LZ4_decompress_generic(
|
|||||||
/* If we're in this block because of the input parsing condition, then we must be on the
|
/* If we're in this block because of the input parsing condition, then we must be on the
|
||||||
* last sequence (or invalid), so we must check that we exactly consume the input.
|
* last sequence (or invalid), so we must check that we exactly consume the input.
|
||||||
*/
|
*/
|
||||||
if ((ip+length>iend-(2+1+LASTLITERALS)) && (ip+length != iend)) { goto _output_error; }
|
if ((ip+length>iend-(2+1+LASTLITERALS)) && (ip+length != iend) && (cpy != oend)) { goto _output_error; }
|
||||||
assert(ip+length <= iend);
|
assert(ip+length <= iend);
|
||||||
/* We are finishing in the middle of a literals segment.
|
/* We are finishing in the middle of a literals segment.
|
||||||
* Break after the copy.
|
* Break after the copy.
|
||||||
|
@ -55,7 +55,7 @@ NB_LOOPS ?= -i1
|
|||||||
|
|
||||||
default: all
|
default: all
|
||||||
|
|
||||||
all: fullbench fuzzer frametest roundTripTest datagen checkFrame
|
all: fullbench fuzzer frametest roundTripTest datagen checkFrame decompress-partial
|
||||||
|
|
||||||
all32: CFLAGS+=-m32
|
all32: CFLAGS+=-m32
|
||||||
all32: all
|
all32: all
|
||||||
@ -104,6 +104,9 @@ datagen : $(PRGDIR)/datagen.c datagencli.c
|
|||||||
checkFrame : lz4frame.o lz4.o lz4hc.o xxhash.o checkFrame.c
|
checkFrame : lz4frame.o lz4.o lz4hc.o xxhash.o checkFrame.c
|
||||||
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
||||||
|
|
||||||
|
decompress-partial: lz4.o decompress-partial.c
|
||||||
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
|
@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
|
||||||
@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
|
@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
|
||||||
@ -114,7 +117,8 @@ clean:
|
|||||||
frametest$(EXT) frametest32$(EXT) \
|
frametest$(EXT) frametest32$(EXT) \
|
||||||
fasttest$(EXT) roundTripTest$(EXT) \
|
fasttest$(EXT) roundTripTest$(EXT) \
|
||||||
datagen$(EXT) checkTag$(EXT) \
|
datagen$(EXT) checkTag$(EXT) \
|
||||||
frameTest$(EXT) lz4_all.c
|
frameTest$(EXT) decompress-partial$(EXT) \
|
||||||
|
lz4_all.c
|
||||||
@$(RM) -rf $(TESTDIR)
|
@$(RM) -rf $(TESTDIR)
|
||||||
@echo Cleaning completed
|
@echo Cleaning completed
|
||||||
|
|
||||||
@ -156,7 +160,7 @@ list:
|
|||||||
check: test-lz4-essentials
|
check: test-lz4-essentials
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-install test-amalgamation listTest
|
test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-install test-amalgamation listTest test-decompress-partial
|
||||||
|
|
||||||
.PHONY: test32
|
.PHONY: test32
|
||||||
test32: CFLAGS+=-m32
|
test32: CFLAGS+=-m32
|
||||||
@ -519,4 +523,8 @@ test-mem: lz4 datagen fuzzer frametest fullbench
|
|||||||
test-mem32: lz4c32 datagen
|
test-mem32: lz4c32 datagen
|
||||||
# unfortunately, valgrind doesn't seem to work with non-native binary...
|
# unfortunately, valgrind doesn't seem to work with non-native binary...
|
||||||
|
|
||||||
|
test-decompress-partial : decompress-partial
|
||||||
|
@echo "\n ---- test decompress-partial ----"
|
||||||
|
./decompress-partial$(EXT)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
49
tests/decompress-partial.c
Normal file
49
tests/decompress-partial.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include "stdio.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "lz4.h"
|
||||||
|
|
||||||
|
const char source[] =
|
||||||
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n"
|
||||||
|
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\n"
|
||||||
|
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\n"
|
||||||
|
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate\n"
|
||||||
|
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat\n"
|
||||||
|
"cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id\n"
|
||||||
|
"est laborum.\n"
|
||||||
|
"\n"
|
||||||
|
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium\n"
|
||||||
|
"doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore\n"
|
||||||
|
"veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim\n"
|
||||||
|
"ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia\n"
|
||||||
|
"consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque\n"
|
||||||
|
"porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur,\n"
|
||||||
|
"adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore\n"
|
||||||
|
"et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis\n"
|
||||||
|
"nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid\n"
|
||||||
|
"ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea\n"
|
||||||
|
"voluptate velit esse quam nihil molestiae consequatur, vel illum qui\n"
|
||||||
|
"dolorem eum fugiat quo voluptas nulla pariatur?\n";
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 2048
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int srcLen = (int)strlen(source);
|
||||||
|
char cmpBuffer[BUFFER_SIZE];
|
||||||
|
char outBuffer[BUFFER_SIZE];
|
||||||
|
int cmpSize;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
cmpSize = LZ4_compress_default(source, cmpBuffer, srcLen, BUFFER_SIZE);
|
||||||
|
|
||||||
|
for (i = cmpSize; i < cmpSize + 10; ++i) {
|
||||||
|
int result = LZ4_decompress_safe_partial(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE);
|
||||||
|
if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) {
|
||||||
|
printf("test decompress-partial error \n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("test decompress-partial OK \n");
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user