X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/blobdiff_plain/f4944c7cf92f243fd5c48361c6012e84f71fb545..0ca5b0e1c6d371465224227f56bab2818cb64d28:/deflate.c diff --git a/deflate.c b/deflate.c index ecae0d0..d614c37 100644 --- a/deflate.c +++ b/deflate.c @@ -2443,9 +2443,16 @@ int deflate_decompress_data(deflate_decompress_ctx *dctx, goto finished; nlen = dctx->bits & 0xFFFF; EATBITS(16); - if (dctx->uncomplen == 0) - dctx->state = OUTSIDEBLK; /* block is empty */ - else + if (dctx->uncomplen != (nlen ^ 0xFFFF)) { + error = DEFLATE_ERR_UNCOMP_HDR; + goto finished; + } + if (dctx->uncomplen == 0) {/* block is empty */ + if (dctx->lastblock) + dctx->state = END; + else + dctx->state = OUTSIDEBLK; + } else dctx->state = UNCOMP_DATA; break; case UNCOMP_DATA: @@ -2458,8 +2465,12 @@ int deflate_decompress_data(deflate_decompress_ctx *dctx, #endif emit_char(dctx, dctx->bits & 0xFF); EATBITS(8); - if (--dctx->uncomplen == 0) - dctx->state = OUTSIDEBLK; /* end of uncompressed block */ + if (--dctx->uncomplen == 0) { /* end of uncompressed block */ + if (dctx->lastblock) + dctx->state = END; + else + dctx->state = OUTSIDEBLK; + } break; case END: /*