int zflush = Z_FINISH;
size_t out_remain = *out_len;
+ if (zstream->in_len && zstream->zerr == Z_STREAM_END) {
+ giterr_set(GITERR_ZLIB, "zlib input had trailing garbage");
+ return -1;
+ }
+
while (out_remain > 0 && zstream->zerr != Z_STREAM_END) {
size_t out_queued, in_queued, out_used, in_used;
assert_zlib_equal(data, strlen(data) + 1, out, outlen);
}
+void test_core_zstream__fails_on_trailing_garbage(void)
+{
+ git_buf deflated = GIT_BUF_INIT, inflated = GIT_BUF_INIT;
+ size_t i = 0;
+
+ /* compress a simple string */
+ git_zstream_deflatebuf(&deflated, "foobar!!", 8);
+
+ /* append some garbage */
+ for (i = 0; i < 10; i++) {
+ git_buf_putc(&deflated, i);
+ }
+
+ cl_git_fail(git_zstream_inflatebuf(&inflated, deflated.ptr, deflated.size));
+
+ git_buf_free(&deflated);
+ git_buf_free(&inflated);
+}
+
void test_core_zstream__buffer(void)
{
git_buf out = GIT_BUF_INIT;