diff --git a/sys/netinet6/ipcomp_core.c b/sys/netinet6/ipcomp_core.c index bf12545ae786..62af1bc6398f 100644 --- a/sys/netinet6/ipcomp_core.c +++ b/sys/netinet6/ipcomp_core.c @@ -252,14 +252,17 @@ do { \ MOREBLOCK(); } - zerror = mode ? inflate(&zs, Z_FINISH) + zerror = mode ? inflate(&zs, Z_SYNC_FLUSH) : deflate(&zs, Z_FINISH); if (zerror == Z_STREAM_END) break; - else if (zerror == Z_OK) - ; /* once more. */ - else { + else if (zerror == Z_OK) { + if (mode && zs.avail_out != 0) + goto terminate; + else + ; /* once more. */ + } else { if (zs.msg) { ipseclog((LOG_ERR, "ipcomp_%scompress: " "%sflate(Z_FINISH): %s\n",