Skip to content

Commit

Permalink
Added unit test for inflate with Z_FINISH and no window.
Browse files Browse the repository at this point in the history
This test decompresses a small git pack object with the text:
"alone in the dark". By providing inflate with Z_FINISH, it should not use a
sliding window according to zlib docs. We purposefully limit the read buffer
size to trigger CHECK mode to bail early.
  • Loading branch information
nmoinvaz committed Nov 22, 2023
1 parent 6592acc commit c093c40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Binary file added test/GH-1600/packobj.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions test/cmake/test-issues.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ add_test(NAME GH-751
-DTEST_NAME=GH-751-test-txt
-DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/GH-751/test.txt
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compress-and-verify.cmake)

set(TEST_COMMAND ${MINIDEFLATE_COMMAND}
"-d;-k;-s;4;-r;25;${CMAKE_CURRENT_SOURCE_DIR}/GH-1600/packobj.gz")
add_test(NAME GH-1600 COMMAND ${TEST_COMMAND})
6 changes: 6 additions & 0 deletions test/minideflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ void inflate_params(FILE *fin, FILE *fout, int32_t read_buf_size, int32_t write_

do {
err = PREFIX(inflate)(&d_stream, flush);

/* Ignore Z_BUF_ERROR if we are finishing and read buffer size is
* purposefully limited */
if (flush == Z_FINISH && err == Z_BUF_ERROR && read_buf_size != BUFSIZE)
err = Z_OK;

if (err == Z_STREAM_END) break;
CHECK_ERR(err, "inflate");

Expand Down

0 comments on commit c093c40

Please sign in to comment.